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 seven 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
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)

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.