Docs menu
Build a scenario
Scenario file Generators vars and const Time and pace Defaults Relationships Schedules Instances Lifecycle Collections Connections Delivery behaviorExpressions
Faker
Names and email addresses often need to describe the same person. Generate one coherent person object when those fields must agree.
The result
The name parts, full name, and email belong to one generated customer:
{"firstName":"Carleton","lastName":"Kuhn","fullName":"Carleton Kuhn","email":"carleton.kuhn@synthetic.test"}
{"firstName":"Emily","lastName":"Hubbard","fullName":"Emily Hubbard","email":"emily.hubbard@example.test"}
Generate coherent customers
defaults:
seed: 42
faker:
locale: en_US
generators:
- name: customers
config:
maxEvents: 2
vars:
customer: =faker(person)
value:
firstName: $customer.firstName
lastName: $customer.lastName
fullName: $customer.fullName
email: $customer.email
faker(path)
faker reads a literal provider path from the locale pack selected by defaults.faker.locale.
defaults:
faker:
locale: en_US
generators:
- name: customers
value:
person: =faker(person)
firstName: =faker(person.firstName)
lastName: =faker(person.lastName)
fullName: =faker(person.fullName)
personEmail: =faker(person.email)
internetEmail: =faker(internet.email)
phone: =faker(phone.number)
city: =faker(address.city)
state: =faker(address.state)
country: =faker(address.country)
company: =faker(company.name)
product: =faker(commerce.productName)
description: =faker(commerce.productDescription)
With seed 42 and locale: en_US:
{"person":{"firstName":"Jessica","lastName":"Schmidt","fullName":"Jessica Schmidt","email":"jessica.schmidt@synthetic.test"},"firstName":"Kailee","lastName":"Austin","fullName":"Karl Ford","personEmail":"catherine.sutton@mail.test","internetEmail":"arden.marvin@mail.test","phone":"(333) 468-9662","city":"Houston Springs","state":"Oregon","country":"United States","company":"Summit Retail Inc","product":"Compact Digital Backpack","description":"A lightweight backpack with a clean finish"}
The leaf calls are independent draws, so firstName and person.firstName need not match. Supported locales: en_US, en_IN, en_AU, and en_GB.
Supported paths
person- an object with matchingfirstName,lastName,fullName, andemailperson.firstNameperson.lastNameperson.middleNameperson.fullNameperson.emailinternet.emailphone.numberaddress.cityaddress.stateaddress.countrycompany.namecommerce.productNamecommerce.productDescription
person.email and internet.email are aliases. Separate leaf calls are independent draws, so use faker(person) when fields need to stay correlated.
Locale and repeatability
Every Faker call uses the scenario locale. If a supported provider has no data in that locale, Synthtraffic falls back to the en_US provider data for that path.
Faker output is deterministic for the same scenario, locale, seed, clock, and sampling order. Moving the expression or changing its path changes its random identity and may change the result.
- Use
nullablefor optional fields such as middle names:=faker(person.middleName, nullable=0.7). - Use
cardinality=Nto reuse a small pool of values. See Modifiers. - Provider paths must be literal and are validated before the run. An unknown path is an error.
For the locale data inventory and caveats, see Faker data.
Next: choose from fixed values.