faker

    Seedable fake data generation for MoonBit, ported from Faker

    Download zip
    Author
    Version
    0.1.1
    License
    MIT
    Last updated
    12 days ago
    Downloads
    44

    No dependencies

    #Faker for MoonBit

    CI

    A native MoonBit port of the Faker checkout recorded in scripts/upstream.json, with all 77 locale datasets, MT19937 random generation, and corresponding entry points for all 271 upstream generator functions. No JavaScript runtime, network connection, or third-party MoonBit dependencies are needed to use the library.

    #Quick start

    Import bobzhang/faker in your moon.pkg:

    import { "bobzhang/faker" }

    ///|
    test "seeded example" {
    let faker = @faker.Faker(seed=42)
    assert_eq(faker.person_full_name(), "Nikita Cormier")
    assert_eq(faker.uuid(), "0d9b0fd3-2248-4649-9245-7c3890921ffc")
    faker.seed(42)
    assert_eq(faker.person_full_name(), "Nikita Cormier")
    }

    Methods use snake_case. Category methods have a prefix, such as person_first_name, internet_email, and location_city. Core number, string, and helper methods use short names, such as int, uuid, and array_element. API.md maps every upstream generator to its MoonBit entry point; pkg.generated.mbti lists the signatures.

    ///|
    test "generating structured test data" {
    let faker = @faker.Faker(seed=123)
    let count = faker.int(min=3, max=8)
    let identifiers = @faker.multiple(_ => faker.uuid(), count~)
    assert_eq(identifiers.length(), count)
    assert_true(faker.internet_email().contains("@"))
    assert_true(@faker.luhn_valid(faker.finance_credit_card_number()))
    assert_eq(faker.finance_iban(country_code="GB").length(), 22)
    }

    #Locales

    Each dataset is an independently importable package, using lowercase locale IDs: bobzhang/faker/locales/en, bobzhang/faker/locales/zh_cn, bobzhang/faker/locales/de_at, etc. The default constructor uses English and base. For another language, pass its locales(): the locale followed by the fallbacks of upstream's prebuilt faker for it (fakerZH_CN is zh_CN, en, base), in descending precedence:

    // Also import "bobzhang/faker/locales/zh_cn" in moon.pkg.

    ///|
    let faker = @faker.Faker(seed=42, locales=@zh_cn.locales())

    ///|
    let name = faker.person_full_name()

    Each package also exports locale(), the dataset alone, for building a custom chain such as [@zh_cn.locale(), @ja.locale(), @base.locale()].

    Fallback occurs per category entry, matching upstream: a defined person.first_name object is used whole. Its missing nested keys do not fall back to another locale. Explicit null disables an entry. Missing or inapplicable data raises an error. Locale::from_json supports custom data; @locale.merge combines locale entries without modifying the input category maps.

    #Reproducibility and compatibility

    The scalar/array seeds and 53-bit MT19937 sequence match Faker. A generator owns its state unless you pass a shared randomizer. Randomizer(precision32=true) provides the earlier 32-bit generator; RandomSource supports custom sources. uniform_distributor and exponential_distributor work with int and float. The committed fixtures compare outputs across five seeds, including the optional arguments of each generator, and the integration suite compares 17 compound generators in every language locale. CI regenerates all of them from the pinned checkout and fails if the committed copies differ.

    Intentional MoonBit adaptations:

    • Faker() uses seed 5489, rather than ambient randomness. Set a seed explicitly when test output is part of a contract.
    • Dates are Int64 Unix milliseconds. Relative dates default to 2020-01-01T00:00:00Z; use set_default_ref_date or a method's ref_date argument to change this. date_iso formats UTC timestamps. UUID v7 and ULID take explicit timestamps.
    • int uses MoonBit's signed 32-bit bounds, defaulting to 0..2147483647. int64 covers JavaScript's safe integer range; big_int supports arbitrary precision. float accepts up to 15 fractional digits and rejects non-finite bounds. BigInt intentionally preserves upstream's decimal/modulo algorithm.
    • On the native backend sin and cos come from the platform C library, so location_nearby_gps_coordinate with an origin can differ from the other backends, and from upstream, in the last digit.
    • Invalid input raises checked FakerError variants. Empty randomizer seed arrays are a documented panic. Custom random sources must satisfy their trait contract. Enum reflection is replaced by explicit arrays of enum values.
    • multiple passes the index to its callback. unique_array takes an array; unique_array_with takes a generator callback. Neither is overloaded.
    • Variable counts/lengths are composed with int or range_to_number. Word filters use min_length, max_length, and LengthStrategy.
    • Color generators return typed channel arrays; color_rgb returns hex. Use color_rgb_channels, color_css, and color_binary for other formats.
    • finance_amount uses fixed decimal formatting; runtime-dependent autoFormat/Intl formatting is not included. Password character regex options are replaced by from_characters/from_reg_exp composition. from_characters takes Unicode characters from a string; use collection helpers to sample multi-character tokens.
    • fake supports the generated no-argument method whitelist and dotted locale definitions. JSON arguments are supported for number.int, string.numeric, helpers.arrayElement, and location.state; arbitrary TypeScript overloads and expression reflection are not reproduced. Templates have a recursion limit of 32. mustache accepts explicit resolver callbacks.
    • from_reg_exp implements Faker's regex-like subset, not a general regex engine. Quantifiers are bounded at one million characters. Map helpers use MoonBit insertion order. No JavaScript object/enum reflection is required.

    These generators create test data. Passwords, mock JWT signatures, and generated payment/cryptocurrency strings are not credentials or usable accounts.

    #Development

    moon check --target all --warn-list +unnecessary_annotation moon test --target all moon fmt moon info

    The .repos/ source checkout is ignored. Generated datasets and test fixtures are committed, so ordinary builds and tests work without it. With the pinned checkout available, rebuild generated files using Node.js with TypeScript stripping support and Python 3:

    node scripts/generate-locales.mjs node scripts/generate-transliteration.mjs node scripts/generate-slugify.mjs node scripts/generate-case-data.mjs node scripts/generate-finance-data.mjs python3 scripts/generate-data-methods.py python3 scripts/api-coverage.py python3 scripts/generate-template-dispatch.py node scripts/generate-parity.mjs node scripts/generate-locale-parity.mjs moon fmt moon info

    Faker source/data attribution and its original MIT notices are retained in LICENSE. Generated Unicode tables use the JavaScript runtime's Unicode version; regenerate them together when updating the port.

    Locale

    Locale definitions. Compose in descending precedence; explicit null disables a definition instead of falling through to a fallback locale.

    RandomSource

    Custom random sources must produce values in [0, 1) and support reseeding.

    Randomizer

    MT19937 with the same scalar/array seeding and 53-bit output as Faker JS.

    FakerError

    pub suberror FakerError {
    InvalidArgument(String)
    MissingDefinition(String)
    InvalidDefinition(String)
    }

    Airline

    pub struct Airline {
    name : String
    iata_code : String
    } derive(
    ToJson
    )

    Airline::to_json

    Airplane

    pub struct Airplane {
    name : String
    iata_type_code : String
    } derive(
    ToJson
    )

    Airplane::to_json

    Airport

    pub struct Airport {
    name : String
    iata_code : String
    } derive(
    ToJson
    )

    Airport::to_json

    Casing

    pub(all) enum Casing {
    Lower
    Upper
    Mixed
    }

    ChemicalElement

    pub struct ChemicalElement {
    symbol : String
    name : String
    atomic_number : Int
    } derive(
    ToJson
    )

    Currency

    pub struct Currency {
    name : String
    code : String
    symbol : String
    numeric_code : String
    } derive(
    ToJson
    )

    Currency::to_json

    Faker

    pub struct Faker {
    randomizer : &
    RandomSource

    locales : Array[
    Locale
    ]
    template_depth : Int
    ref_date : Int64
    }

    Stateful fake data generator. Instances own their random sequence unless a shared randomizer is supplied. Locale definitions are checked in order.

    Faker::Faker

    Construct an English generator. The portable default seed is 5489. Pass locales in descending precedence, including any desired fallbacks.

    Faker::airline_aircraft_type

    fn Faker::airline_aircraft_type(self : Faker) -> String raise

    Faker::airline_airline

    fn Faker::airline_airline(self : Faker) -> Airline raise

    Sample airline.airline from the configured locales.

    Faker::airline_airplane

    fn Faker::airline_airplane(self : Faker) -> Airplane raise

    Sample airline.airplane from the configured locales.

    Faker::airline_airport

    fn Faker::airline_airport(self : Faker) -> Airport raise

    Sample airline.airport from the configured locales.

    Faker::airline_flight_number

    fn Faker::airline_flight_number(self : Faker, length? : Int, add_leading_zeros? : Bool) -> String raise

    Faker::airline_record_locator

    fn Faker::airline_record_locator(self : Faker, allow_numerics? : Bool, allow_visually_similar? : Bool) -> String raise

    Faker::airline_seat

    fn Faker::airline_seat(self : Faker, aircraft_type? : String) -> String raise

    Faker::alpha

    fn Faker::alpha(self : Faker, length? : Int, casing? : Casing, exclude? : String) -> String raise

    Faker::alphanumeric

    fn Faker::alphanumeric(self : Faker, length? : Int, casing? : Casing, exclude? : String) -> String raise

    Faker::animal_bear

    fn Faker::animal_bear(self : Faker) -> String raise

    Sample animal.bear from the configured locales.

    Faker::animal_bird

    fn Faker::animal_bird(self : Faker) -> String raise

    Sample animal.bird from the configured locales.

    Faker::animal_cat

    fn Faker::animal_cat(self : Faker) -> String raise

    Sample animal.cat from the configured locales.

    Faker::animal_cetacean

    fn Faker::animal_cetacean(self : Faker) -> String raise

    Sample animal.cetacean from the configured locales.

    Faker::animal_cow

    fn Faker::animal_cow(self : Faker) -> String raise

    Sample animal.cow from the configured locales.

    Faker::animal_crocodilia

    fn Faker::animal_crocodilia(self : Faker) -> String raise

    Sample animal.crocodilia from the configured locales.

    Faker::animal_dog

    fn Faker::animal_dog(self : Faker) -> String raise

    Sample animal.dog from the configured locales.

    Faker::animal_fish

    fn Faker::animal_fish(self : Faker) -> String raise

    Sample animal.fish from the configured locales.

    Faker::animal_horse

    fn Faker::animal_horse(self : Faker) -> String raise

    Sample animal.horse from the configured locales.

    Faker::animal_insect

    fn Faker::animal_insect(self : Faker) -> String raise

    Sample animal.insect from the configured locales.

    Faker::animal_lion

    fn Faker::animal_lion(self : Faker) -> String raise

    Sample animal.lion from the configured locales.

    Faker::animal_pet_name

    fn Faker::animal_pet_name(self : Faker) -> String raise

    Sample animal.pet_name from the configured locales.

    Faker::animal_rabbit

    fn Faker::animal_rabbit(self : Faker) -> String raise

    Sample animal.rabbit from the configured locales.

    Faker::animal_rodent

    fn Faker::animal_rodent(self : Faker) -> String raise

    Sample animal.rodent from the configured locales.

    Faker::animal_snake

    fn Faker::animal_snake(self : Faker) -> String raise

    Sample animal.snake from the configured locales.

    Faker::animal_type

    fn Faker::animal_type(self : Faker) -> String raise

    Sample animal.type from the configured locales.

    Faker::array_element

    fn[T] Faker::array_element(self : Faker, values : ArrayView[T]) -> T raise

    Faker::array_elements

    fn[T] Faker::array_elements(self : Faker, values : ArrayView[T], count? : Int) -> Array[T] raise

    Faker::array_samples

    fn[T] Faker::array_samples(self : Faker, values : ArrayView[T], count? : Int) -> Array[T] raise

    Faker::big_int

    Arbitrary-precision generator preserving Faker's decimal/modulo algorithm.

    Faker::binary

    fn Faker::binary(self : Faker, length? : Int, prefix? : String) -> String raise

    Faker::book_author

    fn Faker::book_author(self : Faker) -> String raise

    Sample book.author from the configured locales.

    Faker::book_format

    fn Faker::book_format(self : Faker) -> String raise

    Sample book.format from the configured locales.

    Faker::book_genre

    fn Faker::book_genre(self : Faker) -> String raise

    Sample book.genre from the configured locales.

    Faker::book_publisher

    fn Faker::book_publisher(self : Faker) -> String raise

    Sample book.publisher from the configured locales.

    Faker::book_series

    fn Faker::book_series(self : Faker) -> String raise

    Sample book.series from the configured locales.

    Faker::book_title

    fn Faker::book_title(self : Faker) -> String raise

    Sample book.title from the configured locales.

    Faker::boolean

    fn Faker::boolean(self : Faker, probability? : Double) -> Bool raise

    Faker::color_by_css_color_space

    fn Faker::color_by_css_color_space(self : Faker) -> Array[Double] raise

    Faker::color_cmyk

    fn Faker::color_cmyk(self : Faker) -> Array[Double] raise

    Faker::color_css_supported_function

    fn Faker::color_css_supported_function(self : Faker) -> String raise

    Faker::color_css_supported_space

    fn Faker::color_css_supported_space(self : Faker) -> String raise

    Faker::color_hsl

    fn Faker::color_hsl(self : Faker, include_alpha? : Bool) -> Array[Double] raise

    Faker::color_human

    fn Faker::color_human(self : Faker) -> String raise

    Sample color.human from the configured locales.

    Faker::color_hwb

    fn Faker::color_hwb(self : Faker) -> Array[Double] raise

    Faker::color_lab

    fn Faker::color_lab(self : Faker) -> Array[Double] raise

    Faker::color_lch

    fn Faker::color_lch(self : Faker) -> Array[Double] raise

    Faker::color_rgb

    fn Faker::color_rgb(self : Faker, include_alpha? : Bool, prefix? : String, casing? : Casing) -> String raise

    Faker::color_rgb_channels

    fn Faker::color_rgb_channels(self : Faker, include_alpha? : Bool) -> Array[Double] raise

    Faker::color_space

    fn Faker::color_space(self : Faker) -> String raise

    Sample color.space from the configured locales.

    Faker::commerce_department

    fn Faker::commerce_department(self : Faker) -> String raise

    Sample commerce.department from the configured locales.

    Faker::commerce_isbn

    fn Faker::commerce_isbn(self : Faker, variant? : Int, separator? : String) -> String raise

    Faker::commerce_price

    fn Faker::commerce_price(self : Faker, min? : Double, max? : Double, decimals? : Int, symbol? : String) -> String raise

    Faker::commerce_product

    fn Faker::commerce_product(self : Faker) -> String raise

    Sample commerce.product_name.product from the configured locales.

    Faker::commerce_product_adjective

    fn Faker::commerce_product_adjective(self : Faker) -> String raise

    Sample commerce.product_name.adjective from the configured locales.

    Faker::commerce_product_description

    fn Faker::commerce_product_description(self : Faker) -> String raise

    Faker::commerce_product_material

    fn Faker::commerce_product_material(self : Faker) -> String raise

    Sample commerce.product_name.material from the configured locales.

    Faker::commerce_product_name

    fn Faker::commerce_product_name(self : Faker) -> String raise

    Faker::commerce_upc

    fn Faker::commerce_upc(self : Faker, prefix? : String) -> String raise

    Faker::company_buzz_adjective

    fn Faker::company_buzz_adjective(self : Faker) -> String raise

    Sample company.buzz_adjective from the configured locales.

    Faker::company_buzz_noun

    fn Faker::company_buzz_noun(self : Faker) -> String raise

    Sample company.buzz_noun from the configured locales.

    Faker::company_buzz_phrase

    fn Faker::company_buzz_phrase(self : Faker) -> String raise

    Faker::company_buzz_verb

    fn Faker::company_buzz_verb(self : Faker) -> String raise

    Sample company.buzz_verb from the configured locales.

    Faker::company_catch_phrase

    fn Faker::company_catch_phrase(self : Faker) -> String raise

    Faker::company_catch_phrase_adjective

    fn Faker::company_catch_phrase_adjective(self : Faker) -> String raise

    Sample company.adjective from the configured locales.

    Faker::company_catch_phrase_descriptor

    fn Faker::company_catch_phrase_descriptor(self : Faker) -> String raise

    Sample company.descriptor from the configured locales.

    Faker::company_catch_phrase_noun

    fn Faker::company_catch_phrase_noun(self : Faker) -> String raise

    Sample company.noun from the configured locales.

    Faker::company_name

    fn Faker::company_name(self : Faker) -> String raise

    Faker::database_collation

    fn Faker::database_collation(self : Faker) -> String raise

    Sample database.collation from the configured locales.

    Faker::database_column

    fn Faker::database_column(self : Faker) -> String raise

    Sample database.column from the configured locales.

    Faker::database_engine

    fn Faker::database_engine(self : Faker) -> String raise

    Sample database.engine from the configured locales.

    Faker::database_mongodb_object_id

    fn Faker::database_mongodb_object_id(self : Faker) -> String raise

    Faker::database_type

    fn Faker::database_type(self : Faker) -> String raise

    Sample database.type from the configured locales.

    Faker::date_anytime

    fn Faker::date_anytime(self : Faker, ref_date? : Int64) -> Int64 raise

    Faker::date_between

    fn Faker::date_between(self : Faker, from : Int64, to : Int64) -> Int64 raise

    Faker::date_betweens

    fn Faker::date_betweens(self : Faker, from : Int64, to : Int64, count? : Int) -> Array[Int64] raise

    Faker::date_birthdate

    fn Faker::date_birthdate(self : Faker, min? : Int, max? : Int, mode? : String, ref_date? : Int64) -> Int64 raise

    Faker::date_future

    fn Faker::date_future(self : Faker, years? : Int, min_years? : Int, ref_date? : Int64) -> Int64 raise

    Faker::date_month

    fn Faker::date_month(self : Faker, abbreviated? : Bool, context? : Bool) -> String raise

    Faker::date_past

    fn Faker::date_past(self : Faker, years? : Int, min_years? : Int, ref_date? : Int64) -> Int64 raise

    Faker::date_recent

    fn Faker::date_recent(self : Faker, days? : Int, min_days? : Int, ref_date? : Int64) -> Int64 raise

    Faker::date_soon

    fn Faker::date_soon(self : Faker, days? : Int, min_days? : Int, ref_date? : Int64) -> Int64 raise

    Faker::date_time_zone

    fn Faker::date_time_zone(self : Faker) -> String raise

    Sample date.time_zone from the configured locales.

    Faker::date_weekday

    fn Faker::date_weekday(self : Faker, abbreviated? : Bool, context? : Bool) -> String raise

    Faker::definition

    fn Faker::definition(self : Faker, path : String) ->
    Json
    raise

    Faker::enum_value

    fn[T] Faker::enum_value(self : Faker, variants : ArrayView[T]) -> T raise

    Supply the enum's possible values explicitly in MoonBit.

    Faker::fake

    fn Faker::fake(self : Faker, template : String) -> String raise

    Expand Faker method and locale placeholders. Only supported method names and JSON arguments are accepted; this never evaluates JavaScript.

    Faker::finance_account_name

    fn Faker::finance_account_name(self : Faker) -> String raise

    Faker::finance_account_number

    fn Faker::finance_account_number(self : Faker, length? : Int) -> String raise

    Faker::finance_amount

    fn Faker::finance_amount(self : Faker, min? : Double, max? : Double, decimals? : Int, symbol? : String) -> String raise

    Faker::finance_bic

    fn Faker::finance_bic(self : Faker, include_branch_code? : Bool) -> String raise

    Faker::finance_bitcoin_address

    fn Faker::finance_bitcoin_address(self : Faker, family? : String, testnet? : Bool) -> String raise

    Faker::finance_credit_card_cvv

    fn Faker::finance_credit_card_cvv(self : Faker) -> String raise

    Faker::finance_credit_card_issuer

    fn Faker::finance_credit_card_issuer(self : Faker) -> String raise

    Faker::finance_credit_card_number

    fn Faker::finance_credit_card_number(self : Faker, issuer? : String) -> String raise

    Faker::finance_currency

    fn Faker::finance_currency(self : Faker) -> Currency raise

    Sample finance.currency from the configured locales.

    Faker::finance_currency_code

    fn Faker::finance_currency_code(self : Faker) -> String raise

    Faker::finance_currency_name

    fn Faker::finance_currency_name(self : Faker) -> String raise

    Faker::finance_currency_numeric_code

    fn Faker::finance_currency_numeric_code(self : Faker) -> String raise

    Faker::finance_currency_symbol

    fn Faker::finance_currency_symbol(self : Faker) -> String raise

    Faker::finance_ethereum_address

    fn Faker::finance_ethereum_address(self : Faker) -> String raise

    Faker::finance_iban

    fn Faker::finance_iban(self : Faker, country_code? : String, formatted? : Bool) -> String raise

    Faker::finance_litecoin_address

    fn Faker::finance_litecoin_address(self : Faker) -> String raise

    Faker::finance_pin

    fn Faker::finance_pin(self : Faker, length? : Int) -> String raise

    Faker::finance_routing_number

    fn Faker::finance_routing_number(self : Faker) -> String raise

    Faker::finance_transaction_description

    fn Faker::finance_transaction_description(self : Faker) -> String raise

    Faker::finance_transaction_type

    fn Faker::finance_transaction_type(self : Faker) -> String raise

    Sample finance.transaction_type from the configured locales.

    Faker::finance_vat_number

    fn Faker::finance_vat_number(self : Faker, country_code? : String) -> String raise

    Faker::float

    fn Faker::float(self : Faker, min? : Double, max? : Double, multiple_of? : Double, fraction_digits? : Int, distributor? : (&
    RandomSource
    ) -> Double) -> Double raise

    Faker::food_adjective

    fn Faker::food_adjective(self : Faker) -> String raise

    Sample food.adjective from the configured locales.

    Faker::food_description

    fn Faker::food_description(self : Faker) -> String raise

    Faker::food_dish

    fn Faker::food_dish(self : Faker) -> String raise

    Faker::food_ethnic_category

    fn Faker::food_ethnic_category(self : Faker) -> String raise

    Sample food.ethnic_category from the configured locales.

    Faker::food_fruit

    fn Faker::food_fruit(self : Faker) -> String raise

    Sample food.fruit from the configured locales.

    Faker::food_ingredient

    fn Faker::food_ingredient(self : Faker) -> String raise

    Sample food.ingredient from the configured locales.

    Faker::food_meat

    fn Faker::food_meat(self : Faker) -> String raise

    Sample food.meat from the configured locales.

    Faker::food_spice

    fn Faker::food_spice(self : Faker) -> String raise

    Sample food.spice from the configured locales.

    Faker::food_vegetable

    fn Faker::food_vegetable(self : Faker) -> String raise

    Sample food.vegetable from the configured locales.

    Faker::from_characters

    fn Faker::from_characters(self : Faker, characters : String, length? : Int) -> String raise

    Faker::from_reg_exp

    fn Faker::from_reg_exp(self : Faker, pattern : String, ignore_case? : Bool) -> String raise

    Generate from Faker's regex-like subset: character ranges, negation, dot, and ?, *, +, {n}, {min,max} quantifiers. Grouping and backreferences are not supported. A string pattern is used, so anchors are treated literally.

    Faker::git_branch

    fn Faker::git_branch(self : Faker) -> String raise

    Faker::git_commit_date

    fn Faker::git_commit_date(self : Faker, ref_date? : Int64) -> String raise

    Faker::git_commit_entry

    fn Faker::git_commit_entry(self : Faker, merge? : Bool, eol? : String, ref_date? : Int64) -> String raise

    Faker::git_commit_message

    fn Faker::git_commit_message(self : Faker) -> String raise

    Faker::git_commit_sha

    fn Faker::git_commit_sha(self : Faker, length? : Int) -> String raise

    Faker::hacker_abbreviation

    fn Faker::hacker_abbreviation(self : Faker) -> String raise

    Sample hacker.abbreviation from the configured locales.

    Faker::hacker_adjective

    fn Faker::hacker_adjective(self : Faker) -> String raise

    Sample hacker.adjective from the configured locales.

    Faker::hacker_ingverb

    fn Faker::hacker_ingverb(self : Faker) -> String raise

    Sample hacker.ingverb from the configured locales.

    Faker::hacker_noun

    fn Faker::hacker_noun(self : Faker) -> String raise

    Sample hacker.noun from the configured locales.

    Faker::hacker_phrase

    fn Faker::hacker_phrase(self : Faker) -> String raise

    Faker::hacker_verb

    fn Faker::hacker_verb(self : Faker) -> String raise

    Sample hacker.verb from the configured locales.

    Faker::hexadecimal

    fn Faker::hexadecimal(self : Faker, length? : Int, prefix? : String, casing? : Casing) -> String raise

    Faker::image_avatar

    fn Faker::image_avatar(self : Faker) -> String raise

    Faker::image_avatar_git_hub

    fn Faker::image_avatar_git_hub(self : Faker) -> String raise

    Faker::image_data_uri

    fn Faker::image_data_uri(self : Faker, width? : Int, height? : Int, color? : String, base64? : Bool) -> String raise

    Faker::image_person_portrait

    fn Faker::image_person_portrait(self : Faker, size? : Int, sex? : Sex) -> String raise

    Faker::image_url

    fn Faker::image_url(self : Faker, width? : Int, height? : Int) -> String raise

    Faker::image_url_lorem_flickr

    fn Faker::image_url_lorem_flickr(self : Faker, width? : Int, height? : Int, category? : String) -> String raise

    Faker::image_url_picsum_photos

    fn Faker::image_url_picsum_photos(self : Faker, width? : Int, height? : Int, grayscale? : Bool, blur? : Int) -> String raise

    Faker::int

    fn Faker::int(self : Faker, min? : Int, max? : Int, multiple_of? : Int, distributor? : (&
    RandomSource
    ) -> Double) -> Int raise

    Inclusive integer range; multiples are selected uniformly. Equal bounds do not consume randomness. MoonBit Int bounds replace JS's safe-integer range.

    Faker::int64

    fn Faker::int64(self : Faker, min? : Int64, max? : Int64) -> Int64 raise

    Inclusive JS-safe integer range, used for millisecond timestamps.

    Faker::internet_display_name

    fn Faker::internet_display_name(self : Faker, first_name? : String, last_name? : String) -> String raise

    Faker::internet_domain_name

    fn Faker::internet_domain_name(self : Faker) -> String raise

    Faker::internet_domain_suffix

    fn Faker::internet_domain_suffix(self : Faker) -> String raise

    Sample internet.domain_suffix from the configured locales.

    Faker::internet_domain_word

    fn Faker::internet_domain_word(self : Faker) -> String raise

    Faker::internet_email

    fn Faker::internet_email(self : Faker, first_name? : String, last_name? : String, provider? : String, allow_special_characters? : Bool) -> String raise

    Faker::internet_emoji

    fn Faker::internet_emoji(self : Faker, types? : Array[String]) -> String raise

    Faker::internet_example_email

    fn Faker::internet_example_email(self : Faker, first_name? : String, last_name? : String, allow_special_characters? : Bool) -> String raise

    Faker::internet_http_method

    fn Faker::internet_http_method(self : Faker) -> String raise

    Faker::internet_http_status_code

    fn Faker::internet_http_status_code(self : Faker, types? : Array[String]) -> Int raise

    Faker::internet_ip

    fn Faker::internet_ip(self : Faker) -> String raise

    Faker::internet_ipv4

    fn Faker::internet_ipv4(self : Faker, cidr? : String, network? : String) -> String raise

    Generate an address inside cidr, or inside the named network (any, loopback, private-a, private-b, private-c, test-net-1, test-net-2, test-net-3, link-local, multicast) when cidr is absent.

    Faker::internet_ipv6

    fn Faker::internet_ipv6(self : Faker) -> String raise

    Faker::internet_jwt

    fn Faker::internet_jwt(self : Faker, header? :
    Json
    , payload? :
    Json
    , ref_date? : Int64) -> String raise

    Generate a mock JWT. Its random signature is not a cryptographic signature.

    Faker::internet_jwt_algorithm

    fn Faker::internet_jwt_algorithm(self : Faker) -> String raise

    Sample internet.jwt_algorithm from the configured locales.

    Faker::internet_mac

    fn Faker::internet_mac(self : Faker, separator? : String) -> String raise

    Faker::internet_password

    fn Faker::internet_password(self : Faker, length? : Int, memorable? : Bool, prefix? : String) -> String raise

    Generate a fake password; not suitable for actual credentials.

    Faker::internet_port

    fn Faker::internet_port(self : Faker) -> Int raise

    Faker::internet_protocol

    fn Faker::internet_protocol(self : Faker) -> String raise

    Faker::internet_url

    fn Faker::internet_url(self : Faker, protocol? : String, append_slash? : Bool) -> String raise

    Faker::internet_user_agent

    fn Faker::internet_user_agent(self : Faker) -> String raise

    Faker::internet_username

    fn Faker::internet_username(self : Faker, first_name? : String, last_name? : String) -> String raise

    Faker::location_building_number

    fn Faker::location_building_number(self : Faker) -> String raise

    Faker::location_cardinal_direction

    fn Faker::location_cardinal_direction(self : Faker, abbreviated? : Bool) -> String raise

    Faker::location_city

    fn Faker::location_city(self : Faker) -> String raise

    Faker::location_continent

    fn Faker::location_continent(self : Faker) -> String raise

    Sample location.continent from the configured locales.

    Faker::location_country

    fn Faker::location_country(self : Faker) -> String raise

    Sample location.country from the configured locales.

    Faker::location_country_code

    fn Faker::location_country_code(self : Faker, variant? : String) -> String raise

    Faker::location_county

    fn Faker::location_county(self : Faker) -> String raise

    Sample location.county from the configured locales.

    Faker::location_direction

    fn Faker::location_direction(self : Faker, abbreviated? : Bool) -> String raise

    Faker::location_language

    fn Faker::location_language(self : Faker) -> Language raise

    Sample location.language from the configured locales.

    Faker::location_latitude

    fn Faker::location_latitude(self : Faker, min? : Double, max? : Double, precision? : Int) -> Double raise

    Faker::location_longitude

    fn Faker::location_longitude(self : Faker, min? : Double, max? : Double, precision? : Int) -> Double raise

    Faker::location_nearby_gps_coordinate

    fn Faker::location_nearby_gps_coordinate(self : Faker, origin? : (Double, Double), radius? : Double, metric? : Bool) -> (Double, Double) raise

    Faker::location_ordinal_direction

    fn Faker::location_ordinal_direction(self : Faker, abbreviated? : Bool) -> String raise

    Faker::location_postal_address

    fn Faker::location_postal_address(self : Faker) -> String raise

    Faker::location_secondary_address

    fn Faker::location_secondary_address(self : Faker) -> String raise

    Faker::location_state

    fn Faker::location_state(self : Faker, abbreviated? : Bool) -> String raise

    Faker::location_street

    fn Faker::location_street(self : Faker) -> String raise

    Faker::location_street_address

    fn Faker::location_street_address(self : Faker, full? : Bool) -> String raise

    Faker::location_time_zone

    fn Faker::location_time_zone(self : Faker) -> String raise

    Sample location.time_zone from the configured locales.

    Faker::location_zip_code

    fn Faker::location_zip_code(self : Faker, format? : String, state? : String) -> String raise

    Faker::lorem_lines

    fn Faker::lorem_lines(self : Faker, count? : Int) -> String raise

    Faker::lorem_paragraph

    fn Faker::lorem_paragraph(self : Faker, count? : Int) -> String raise

    Faker::lorem_paragraphs

    fn Faker::lorem_paragraphs(self : Faker, count? : Int, separator? : String) -> String raise

    Faker::lorem_sentence

    fn Faker::lorem_sentence(self : Faker, count? : Int) -> String raise

    Faker::lorem_sentences

    fn Faker::lorem_sentences(self : Faker, count? : Int, separator? : String) -> String raise

    Faker::lorem_slug

    fn Faker::lorem_slug(self : Faker, count? : Int) -> String raise

    Faker::lorem_text

    fn Faker::lorem_text(self : Faker) -> String raise

    Faker::lorem_word

    fn Faker::lorem_word(self : Faker, min_length? : Int, max_length? : Int, strategy? : LengthStrategy) -> String raise

    Faker::lorem_words

    fn Faker::lorem_words(self : Faker, count? : Int) -> String raise

    Faker::maybe

    fn[T] Faker::maybe(self : Faker, generate : () -> T raise, probability? : Double) -> T? raise

    Faker::medical_allergen

    fn Faker::medical_allergen(self : Faker) -> String raise

    Sample medical.allergen from the configured locales.

    Faker::medical_blood_type

    fn Faker::medical_blood_type(self : Faker) -> String raise

    Sample medical.blood_type from the configured locales.

    Faker::medical_condition

    fn Faker::medical_condition(self : Faker) -> String raise

    Sample medical.condition from the configured locales.

    Faker::medical_department

    fn Faker::medical_department(self : Faker) -> String raise

    Sample medical.department from the configured locales.

    Faker::medical_drug_name

    fn Faker::medical_drug_name(self : Faker) -> String raise

    Sample medical.drug_name from the configured locales.

    Faker::medical_procedure

    fn Faker::medical_procedure(self : Faker) -> String raise

    Sample medical.procedure from the configured locales.

    Faker::medical_specialty

    fn Faker::medical_specialty(self : Faker) -> String raise

    Sample medical.specialty from the configured locales.

    Faker::medical_symptom

    fn Faker::medical_symptom(self : Faker) -> String raise

    Sample medical.symptom from the configured locales.

    Faker::music_album

    fn Faker::music_album(self : Faker) -> String raise

    Sample music.album from the configured locales.

    Faker::music_artist

    fn Faker::music_artist(self : Faker) -> String raise

    Sample music.artist from the configured locales.

    Faker::music_genre

    fn Faker::music_genre(self : Faker) -> String raise

    Sample music.genre from the configured locales.

    Faker::music_song_name

    fn Faker::music_song_name(self : Faker) -> String raise

    Sample music.song_name from the configured locales.

    Faker::nanoid

    fn Faker::nanoid(self : Faker, length? : Int) -> String raise

    Faker::number_binary

    fn Faker::number_binary(self : Faker, min? : Int, max? : Int) -> String raise

    Faker::number_hex

    fn Faker::number_hex(self : Faker, min? : Int, max? : Int) -> String raise

    Faker::number_octal

    fn Faker::number_octal(self : Faker, min? : Int, max? : Int) -> String raise

    Faker::numeric

    fn Faker::numeric(self : Faker, length? : Int, allow_leading_zeros? : Bool, exclude? : String) -> String raise

    Faker::object_entry

    fn[T] Faker::object_entry(self : Faker, values : Map[String, T]) -> (String, T) raise

    Faker::object_key

    fn[T] Faker::object_key(self : Faker, values : Map[String, T]) -> String raise

    Faker::object_value

    fn[T] Faker::object_value(self : Faker, values : Map[String, T]) -> T raise

    Faker::octal

    fn Faker::octal(self : Faker, length? : Int, prefix? : String) -> String raise

    Faker::person_bio

    fn Faker::person_bio(self : Faker) -> String raise

    Faker::person_first_name

    fn Faker::person_first_name(self : Faker, sex? : Sex) -> String raise

    Faker::person_full_name

    fn Faker::person_full_name(self : Faker, first_name? : String, last_name? : String, sex? : Sex) -> String raise

    Faker::person_gender

    fn Faker::person_gender(self : Faker) -> String raise

    Sample person.gender from the configured locales.

    Faker::person_job_area

    fn Faker::person_job_area(self : Faker) -> String raise

    Sample person.job_area from the configured locales.

    Faker::person_job_descriptor

    fn Faker::person_job_descriptor(self : Faker) -> String raise

    Sample person.job_descriptor from the configured locales.

    Faker::person_job_title

    fn Faker::person_job_title(self : Faker) -> String raise

    Faker::person_job_type

    fn Faker::person_job_type(self : Faker) -> String raise

    Sample person.job_type from the configured locales.

    Faker::person_last_name

    fn Faker::person_last_name(self : Faker, sex? : Sex) -> String raise

    Faker::person_middle_name

    fn Faker::person_middle_name(self : Faker, sex? : Sex) -> String raise

    Faker::person_prefix

    fn Faker::person_prefix(self : Faker, sex? : Sex) -> String raise

    Faker::person_sex

    fn Faker::person_sex(self : Faker) -> String raise

    Sample person.sex from the configured locales.

    Faker::person_sex_type

    fn Faker::person_sex_type(self : Faker, include_generic? : Bool) -> Sex raise

    Faker::person_suffix

    fn Faker::person_suffix(self : Faker) -> String raise

    Sample person.suffix from the configured locales.

    Faker::person_zodiac_sign

    fn Faker::person_zodiac_sign(self : Faker) -> String raise

    Sample person.western_zodiac_sign from the configured locales.

    Faker::phone_imei

    fn Faker::phone_imei(self : Faker) -> String raise

    Faker::phone_number

    fn Faker::phone_number(self : Faker, style? : String) -> String raise

    Faker::random

    fn Faker::random(self : Faker) -> Double

    Faker::range_to_number

    fn Faker::range_to_number(self : Faker, range : NumberOrRange) -> Int raise

    Faker::replace_credit_card_symbols

    fn Faker::replace_credit_card_symbols(self : Faker, pattern? : String, symbol? : Char) -> String raise

    Faker::replace_symbols

    fn Faker::replace_symbols(self : Faker, template : String) -> String raise

    Faker::roman_numeral

    fn Faker::roman_numeral(self : Faker, min? : Int, max? : Int) -> String raise

    Faker::sample

    fn Faker::sample(self : Faker, path : String) -> String raise

    Sample any upstream string-array definition by its dotted path.

    Faker::science_chemical_element

    fn Faker::science_chemical_element(self : Faker) -> ChemicalElement raise

    Sample science.chemical_element from the configured locales.

    Faker::science_unit

    fn Faker::science_unit(self : Faker) -> ScienceUnit raise

    Sample science.unit from the configured locales.

    Faker::seed

    fn Faker::seed(self : Faker, seed : UInt) -> Unit

    Faker::seed_array

    fn Faker::seed_array(self : Faker, seeds : ArrayView[UInt]) -> Unit

    Faker::set_default_ref_date

    fn Faker::set_default_ref_date(self : Faker, timestamp_ms : Int64) -> Unit raise

    Set the deterministic reference time (Unix milliseconds) used by relative dates.

    Faker::shuffle

    fn[T] Faker::shuffle(self : Faker, values : ArrayView[T]) -> Array[T] raise

    Faker::string_sample

    fn Faker::string_sample(self : Faker, length? : Int) -> String raise

    Faker::symbol

    fn Faker::symbol(self : Faker, length? : Int) -> String raise

    Faker::system_common_file_ext

    fn Faker::system_common_file_ext(self : Faker) -> String raise

    Faker::system_common_file_name

    fn Faker::system_common_file_name(self : Faker, extension? : String) -> String raise

    Faker::system_common_file_type

    fn Faker::system_common_file_type(self : Faker) -> String raise

    Faker::system_cron

    fn Faker::system_cron(self : Faker, include_year? : Bool, include_non_standard? : Bool) -> String raise

    Faker::system_directory_path

    fn Faker::system_directory_path(self : Faker) -> String raise

    Faker::system_file_ext

    fn Faker::system_file_ext(self : Faker, mime_type? : String) -> String raise

    Faker::system_file_name

    fn Faker::system_file_name(self : Faker, extension_count? : Int) -> String raise

    Faker::system_file_path

    fn Faker::system_file_path(self : Faker) -> String raise

    Faker::system_file_type

    fn Faker::system_file_type(self : Faker) -> String raise

    Faker::system_mime_type

    fn Faker::system_mime_type(self : Faker) -> String raise

    Faker::system_network_interface

    fn Faker::system_network_interface(self : Faker, interface_type? : String, schema? : String) -> String raise

    Faker::system_semver

    fn Faker::system_semver(self : Faker) -> String raise

    Faker::ulid

    fn Faker::ulid(self : Faker, timestamp_ms : Int64) -> String raise

    A ULID with an explicit timestamp, avoiding implicit wall-clock dependencies.

    Faker::unique_array

    fn[T : Eq] Faker::unique_array(self : Faker, values : ArrayView[T], count : Int) -> Array[T] raise

    Faker::uuid

    fn Faker::uuid(self : Faker) -> String raise

    A version 4 UUID; like Faker, this is deterministic and not cryptographic.

    Faker::uuid_v7

    fn Faker::uuid_v7(self : Faker, timestamp_ms : Int64) -> String raise

    A version 7 UUID with an explicit Unix timestamp in milliseconds.

    Faker::vehicle_bicycle

    fn Faker::vehicle_bicycle(self : Faker) -> String raise

    Sample vehicle.bicycle_type from the configured locales.

    Faker::vehicle_color

    fn Faker::vehicle_color(self : Faker) -> String raise

    Faker::vehicle_fuel

    fn Faker::vehicle_fuel(self : Faker) -> String raise

    Sample vehicle.fuel from the configured locales.

    Faker::vehicle_manufacturer

    fn Faker::vehicle_manufacturer(self : Faker) -> String raise

    Sample vehicle.manufacturer from the configured locales.

    Faker::vehicle_model

    fn Faker::vehicle_model(self : Faker) -> String raise

    Sample vehicle.model from the configured locales.

    Faker::vehicle_type

    fn Faker::vehicle_type(self : Faker) -> String raise

    Sample vehicle.type from the configured locales.

    Faker::vehicle_vehicle

    fn Faker::vehicle_vehicle(self : Faker) -> String raise

    Faker::vehicle_vin

    fn Faker::vehicle_vin(self : Faker) -> String raise

    Faker::vehicle_vrm

    fn Faker::vehicle_vrm(self : Faker) -> String raise

    Faker::weighted_array_element

    fn[T] Faker::weighted_array_element(self : Faker, values : ArrayView[(Double, T)]) -> T raise

    Faker::word_adjective

    fn Faker::word_adjective(self : Faker, min_length? : Int, max_length? : Int, strategy? : LengthStrategy) -> String raise

    Faker::word_adverb

    fn Faker::word_adverb(self : Faker, min_length? : Int, max_length? : Int, strategy? : LengthStrategy) -> String raise

    Faker::word_conjunction

    fn Faker::word_conjunction(self : Faker, min_length? : Int, max_length? : Int, strategy? : LengthStrategy) -> String raise

    Faker::word_interjection

    fn Faker::word_interjection(self : Faker, min_length? : Int, max_length? : Int, strategy? : LengthStrategy) -> String raise

    Faker::word_noun

    fn Faker::word_noun(self : Faker, min_length? : Int, max_length? : Int, strategy? : LengthStrategy) -> String raise

    Faker::word_preposition

    fn Faker::word_preposition(self : Faker, min_length? : Int, max_length? : Int, strategy? : LengthStrategy) -> String raise

    Faker::word_sample

    fn Faker::word_sample(self : Faker, min_length? : Int, max_length? : Int, strategy? : LengthStrategy) -> String raise

    Faker::word_verb

    fn Faker::word_verb(self : Faker, min_length? : Int, max_length? : Int, strategy? : LengthStrategy) -> String raise

    Faker::word_words

    fn Faker::word_words(self : Faker, count? : Int) -> String raise

    Language

    pub struct Language {
    name : String
    alpha2 : String
    alpha3 : String
    } derive(
    ToJson
    )

    Language::to_json

    LengthStrategy

    pub(all) enum LengthStrategy {
    Fail
    Closest
    Shortest
    Longest
    AnyLength
    }

    NumberOrRange

    pub(all) enum NumberOrRange {
    Fixed(Int)
    Range(min~ : Int, max~ : Int)
    }

    ScienceUnit

    pub struct ScienceUnit {
    name : String
    symbol : String
    } derive(
    ToJson
    )

    Sex

    pub(all) enum Sex {
    Female
    Male
    Generic
    }

    color_binary

    fn color_binary(values : ArrayView[Double]) -> String

    color_css

    fn color_css(values : ArrayView[Double], model? : String, space? : String) -> String raise

    Format generated color channels as CSS. The model determines channel count.

    date_iso

    fn date_iso(timestamp_ms : Int64) -> String raise

    Format a Unix millisecond timestamp in ISO 8601 UTC, independently of backend.

    exponential_distributor

    fn exponential_distributor(base? : Double, bias? : Double) -> ((&
    RandomSource
    ) -> Double) raise

    luhn_valid

    fn luhn_valid(value : String) -> Bool

    multiple

    fn[T] multiple(generate : (Int) -> T raise, count? : Int) -> Array[T] raise

    Call generate with each index in 0..<count and collect the results.

    mustache

    fn mustache(template : String, values : Map[String, () -> String raise]) -> String raise

    Substitute placeholders without evaluating code. Unknown keys remain intact.

    slugify

    fn slugify(value : String) -> String

    Decompose accented characters (NFKD), drop combining marks, replace spaces with hyphens and remove everything outside [A-Za-z0-9_.-].

    uniform_distributor

    fn uniform_distributor() -> ((&
    RandomSource
    ) -> Double)

    unique_array_with

    fn[T : Eq] unique_array_with(generate : () -> T raise, count : Int) -> Array[T]

    Call generate until count distinct values are collected, giving up after 1000 * count attempts. As upstream, an error raised by generate ends the collection early instead of propagating.