fake
Module Export
fake <kind> [generator] [<options>]Generates a fake business/demo value or an infinite generator of a given kind.
The fake macro generates a value of the kind that follows it. Without the generator keyword it produces a single value; with it, an infinite iterator of that kind.
Every kind accepts seed: text | number and locale: 'en' | 'sv'.
v1 catalog
| Kind | Output |
|---|---|
firstName | text |
lastName | text |
fullName | text — first + last |
email | text — derived from a generated name + example domain |
phoneNumber | text — locale-formatted |
companyName | text |
sentence | text — lorem-style sentence (locale-independent) |
address | record { street, city, postalCode, country } |
person | record { firstName, lastName, email, phoneNumber, address } |
company | record { name, email, phoneNumber, website, address } |
product | record { name, sku, price } |
Examples
Names and contact details
import 'fake'
from fake firstNamefrom fake fullName { seed = 'demo' }from fake email { seed = 3 }A localized value
import 'fake'
from fake fullName { locale = 'sv', seed = 9 }A coherent person record
The email is derived from the generated name and every field respects the locale:
import 'fake'
from fake person { seed = 6 }A reproducible dataset
Use the generator form with take to build a demo dataset from a single seed:
import 'fake'import 'iterators'
from fake email generator { seed = 42 } take 5Accessing composite fields
import 'fake'
let a = fake address { seed = 5 }from a.city