Skip to content

Generators

A generator block declares a named source of faker data. Calling generate("<name>") from any expression returns a value produced by that generator. Output is deterministic for a given seed, see Determinism below.

generator "<type>" "<name>" {
# type-specific attributes
}

The first label is the generator type (one of seventeen built-ins). The second is the name you reference from generate(...).

TypeReturnsUse for
emailstringTest email addresses
passwordstringThrowaway passwords with configurable policy
timezonestringIANA timezone identifiers
localestringBCP-47 locale tags
personobjectFirst name, last name, gender, full name
mac_addressstringMAC addresses
bytesstring (hex / base64)Random byte payloads
datestring (YYYY-MM-DD)Replayable calendar dates (birth, contract)
datetimestring (RFC3339 UTC)Replayable timestamps (publication, events)
unix_timenumber (int64 seconds)Replayable Unix timestamps
sirenstring (9 digits)French SIREN business identifier (Luhn)
siretstring (14 digits)French SIRET establishment identifier (Luhn)
einstring (NN-NNNNNNN)US Employer Identification Number
dunsstring (9 digits)Dun & Bradstreet number
leistring (20 alphanumeric)ISO 17442 Legal Entity Identifier
vat_numberstringEU VAT registration number
euidstringBRIS EU Unique Identifier
generator "email" "user_email" {
prefix = "qa-" // optional, prepended after the random local-part
domain = "example.com" // optional, defaults to a faker domain
}
AttributeTypeDefaultNotes
prefixstring""Prepended to the local-part for filtering.
domainstringfaker defaultOverrides the random domain.
generate("user_email") // "[email protected]"
generator "password" "strong_password" {
length = 16
min_upper = 1
min_lower = 1
min_digit = 1
min_special = 1
specials = "!@#$%^&*"
}
AttributeTypeDefaultNotes
lengthnumber12Total length of the generated password.
min_uppernumber0Minimum count of uppercase letters.
min_lowernumber0Minimum count of lowercase letters.
min_digitnumber0Minimum count of digits.
min_specialnumber0Minimum count of characters from the specials alphabet.
specialsstringa default punctuation setCharacters considered “special” for min_special.

The sum of min_* constraints must not exceed length; the parser rejects impossible combinations.

generator "timezone" "tz" {}

No options. Returns an IANA timezone string (e.g. "America/New_York", "Europe/Paris").

generator "locale" "loc" {
separator = "-" // "-" → "en-US"; "_" → "en_US"; default "-"
}
AttributeTypeDefaultNotes
separatorstring"-"Glue character between language and region segments.

Returns a BCP-47 tag (e.g. "en-US", "fr_FR").

generator "person" "demo_person" {
gender = "female" // optional: "male", "female", omit for random
}
AttributeTypeDefaultNotes
genderstringrandomConstrain to "male" or "female".

Returns an object:

generate("demo_person")
// {
// first_name = "Alice"
// last_name = "Martin"
// gender = "female"
// name = "Alice Martin"
// }
generator "mac_address" "mac" {
prefix = "aa:bb" // optional, fixed leading octets
separator = "-" // optional, ":" | "-" | "" (default ":")
lowercase = true // optional, default false (uppercase hex)
}
AttributeTypeDefaultNotes
prefixstring""Fixed leading octets (with separator).
separatorstring":"Glue between octets. Use "" for compact.
lowercaseboolfalseEmit lowercase hex.
generator "bytes" "trace_id" {
length = 8 // optional, default 16, count of bytes (not hex chars)
encoding = "hex" // optional, "hex" (default) | "base64"
}
AttributeTypeDefaultNotes
lengthnumber16Number of bytes generated (before encoding).
encodingstring"hex"Output encoding. "hex" doubles length; "base64" is shorter.
generate("trace_id") // "7f3a4c91" (length=4 hex)

Replayable calendar dates, formatted as YYYY-MM-DD. Both bounds are required and inclusive; they are normalized to whole UTC days (any clock component is ignored). from == to always returns that exact date.

generator "date" "birth_date" {
from = "1980-01-01" // required, YYYY-MM-DD
to = "2006-12-31" // required, YYYY-MM-DD
}
AttributeTypeDefaultNotes
fromstringRequired. Inclusive lower bound (UTC).
tostringRequired. Inclusive upper bound (UTC).
generate("birth_date") // "1994-07-18"

Replayable timestamps as RFC3339 UTC strings (always Z). Both bounds are required and inclusive, compared at second granularity. Inputs are RFC3339 (with a timezone offset) and converted to UTC; the output is always UTC.

generator "datetime" "published_at" {
from = "2024-01-01T00:00:00Z" // required, RFC3339
to = "2024-12-31T23:59:59Z" // required, RFC3339
}
AttributeTypeDefaultNotes
fromstringRequired. Inclusive lower bound (RFC3339).
tostringRequired. Inclusive upper bound (RFC3339).
generate("published_at") // "2024-07-18T12:34:56Z"

Replayable Unix timestamps as a number (int64 seconds), not a string, handy for APIs that expect an epoch. Both bounds are required, inclusive, RFC3339, compared at second granularity in UTC.

generator "unix_time" "event_ts" {
from = "2024-01-01T00:00:00Z" // required, RFC3339
to = "2024-12-31T23:59:59Z" // required, RFC3339
}
AttributeTypeDefaultNotes
fromstringRequired. Inclusive lower bound (RFC3339).
tostringRequired. Inclusive upper bound (RFC3339).
json = {
created_at = generate("event_ts") // 1721306096 (number)
}

French SIREN business identifier: 9 decimal digits with a valid Luhn check digit. No attributes.

generator "siren" "company_siren" {}
generate("company_siren") // "552100554"

French SIRET establishment identifier: 14 decimal digits with a valid Luhn check digit. The first 9 digits form a Luhn-valid SIREN. No attributes.

generator "siret" "company_siret" {}
generate("company_siret") // "55210055400024"

US Employer Identification Number formatted as NN-NNNNNNN. The two-digit prefix is drawn from the IRS published campus code list; the seven-digit body is random with no published checksum. No attributes.

generator "ein" "company_ein" {}
generate("company_ein") // "47-8392016"

Dun & Bradstreet DUNS number: 9 decimal digits, format only (no public checksum). No attributes.

generator "duns" "company_duns" {}
generate("company_duns") // "804613259"

ISO 17442 Legal Entity Identifier: 20 alphanumeric characters laid out as a 4-character LOU prefix, two reserved zeroes, a 12-character entity code, and a 2-digit ISO 7064 mod 97-10 check. No attributes.

generator "lei" "company_lei" {}
generate("company_lei") // "Q8B400X1NLEZ6V3K7C82"

EU VAT registration number. Each country uses its own algorithm: Luhn for IT, mod 97 for FR and BE, mod 11 for PT and SK, format-only for the remaining 22 EU member states (correct length and charset, no checksum).

generator "vat_number" "company_vat" {
country = "FR" // optional, ISO 3166-1 alpha-2 EU member code
}
AttributeTypeDefaultNotes
countrystringrandom EU memberForces the country prefix (AT, BE, BG, CY, CZ, DE, DK, EE, EL, ES, FI, FR, HR, HU, IE, IT, LT, LU, LV, MT, NL, PL, PT, RO, SE, SI, SK). Empty or unknown values fall back to a random EU member.
generate("company_vat") // "FR55552100554"

BRIS-style EU Unique Identifier per Regulation (EU) 2015/884. The value has the shape CC.RegisterID.EntityID.Check where Check is an ISO 7064 mod 97-10 over the unpunctuated payload.

generator "euid" "company_euid" {
country = "FR" // optional, ISO 3166-1 alpha-2 EU member code
}
AttributeTypeDefaultNotes
countrystringrandom EU memberForces the country prefix. Empty or unknown values fall back to a random EU member.
generate("company_euid") // "FR.RCS.552100554.47"

Every generate(...) call mixes:

  • the global --seed
  • the scenario name
  • the step name
  • the generator name
  • the expression path (where in the step body the call lives)

So two calls to the same generator in the same step produce different values, the expression path differs. To reuse a generated value (for example, a password and its confirmation field), generate it once into a vars or capture block and reference that:

step "http" "register" {
vars {
password = generate("strong_password")
}
request {
body {
json = {
password = vars.password
password_confirm = vars.password // same value
}
}
}
}

Identical runs produce identical values regardless of --parallel, regardless of retry attempts. This is the core property that makes Tales suites replayable. See the Deterministic test data guide for more.