Docs menu
Build a scenario
Scenario file Generators vars and const Time and pace Defaults Relationships Schedules Instances Lifecycle Collections Connections Delivery behaviorExpressions
Modifiers
Modifiers change how a supported function returns its value. They are named arguments, and the compiler rejects a modifier on a function that does not support it.
The result
nullable=1 always produces null, optional=1 removes the field, and cardinality=1 reuses one value:
{"amount":20.00,"middleName":null,"segment":"retail"}
{"amount":20.00,"middleName":null,"segment":"retail"}
Modify generated order fields
defaults:
seed: 42
generators:
- name: orders
config:
maxEvents: 2
value:
amount: =uniform(19.995, 19.995, round=2)
middleName: =faker(person.middleName, nullable=1)
couponCode: =string(8, optional=1)
segment: =oneOf(retail, cardinality=1)
Null and omitted fields
nullable=Preturnsnullwith probabilityP, from0to1:=faker(person.middleName, nullable=0.7).optional=Pomits the containing object field with probabilityP:couponCode: =string(8, optional=0.8).
optional removes the field entirely; it does not return null. Both probabilities must be literal numbers from 0 to 1.
Value pools and uniqueness
cardinality=Nbuilds a deterministic pool ofNdistinct values, then reuses values from that pool:=faker(company.name, cardinality=20).unique=truerejects values already returned by the same expression stream:=oneOf(pending, shipped, unique=true).
cardinality must be a positive integer, and unique must be written exactly as unique=true. Synthtraffic tries up to 10,000 draws to satisfy a new pool or unique value, then stops with an exhaustion error. A requested cardinality larger than the function’s possible output—such as three unique values from bool()—cannot succeed. Use unique=true on small sets such as oneOf or bool. uuid() already draws from a large space, so you do not need it there.
Numeric output
round=Nrounds toNdecimal places and preserves that scale in JSON.Nmust be a non-negative integer.min=Xandmax=Xclampnormaloutput after generation and before rounding.
price: =uniform(10, 100, round=2)
score: =normal(mean=50, sd=10, min=0, max=100, round=1)
total: =multiply($unitPrice, $quantity, round=2)
With seed 42 and unitPrice: 19.99, quantity: 3:
{"price":41.91,"score":54.6,"unitPrice":19.99,"quantity":3,"total":59.97}
Supported functions
nullable,optional,cardinality, andunique:bool,bytes,string,int,float,faker,uuid,ulid,uniform,normal, andoneOf.nullableandoptionalonly:easingandeasingChain.round:float,uniform,normal,add,subtract,multiply,divide,pow,min,max,sum,avg,easing, andeasingChain.minandmaxas named clamps:normalonly.
Functions not listed for a modifier reject it during validation.
Next: calculate numeric values.