Fakererer
A pure Elixir library for generating fake data.
Fakererer is a rework of Fakerer (which itself was a fork of elixirs/faker). It uses Fakererer.* module names with the OTP application name :fakererer.
Credit
Fakererer stands on the shoulders of the original Faker library by Igor Kapkov (@igas) and contributors, and the Fakerer fork by Art Kay. All locale data, generators, and patterns originate from their work. The MIT license is preserved.
Quickstart
add the dep to your
mix.exs:defp deps do[{:fakererer, "~> 0.2", only: :test}]endrun:
mix deps.getadd
Fakererer.start()totest/test_helper.exs:ExUnit.start()Fakererer.start()jump to usage examples.
Requirements
- OTP 26+
- Elixir 1.16+
Usage
See documentation and usage examples.
Internationalization (i18n)
Fakererer supports multiple locales with Vietnamese (vi) as a first-class citizen.
Supported Locales
:en- English (default):vi- Vietnamese:da- Danish:es- Spanish:fr- French:hy- Armenian:it- Italian:pt_br- Brazilian Portuguese:ru- Russian:de- German:pt_pt- Portuguese:en_us- US English:en_gb- British English
Setting the Locale
# Start with a specific locale
Fakererer.start(:vi)
# Or set it at runtime
Fakererer.locale(:vi)
Vietnamese Locale
The Vietnamese locale (:vi) provides localized data for:
- Person: Vietnamese names (Nguyễn Văn A, Trần Thị B, etc.)
- Address: Vietnamese cities, states, street names, zip codes
- Color: Vietnamese color names
- Company: Vietnamese company prefixes and buzzwords
- Commerce: Vietnamese product names and departments
- Food: Vietnamese dishes and ingredients
- Beer: Vietnamese beer brands
- Vehicle: Vehicle makes and models
- Phone: Vietnamese phone number formats
- Cat: Vietnamese cat names and breeds
- Industry: Vietnamese industry sectors
Fakererer.start(:vi)
Fakererer.Person.name()
# => "Nguyễn Văn Minh"
Fakererer.Address.city()
# => "Thành phố Hà Nội"
Fakererer.Food.dish()
# => "Phở"
Troubleshooting
If you get a message like the one below when you call
Fakererer.Address.city/0, you need to add:fakerererto your application's mix file, in theapplicationsfunction, as above. (Yes,:fakererer- that's both the Hex package name and the OTP application name.)** (FunctionClauseError) no function clause matching in Fakererer.Address.city_count/1lib/fakererer/address.ex:48: Fakererer.Address.city_count(nil)lib/fakererer/address.ex:41: Fakererer.Address.city/0
Tools
Fakererer was designed as a lightweight library, that's why it can be easily used with other tools.
Templating
You can build templates for testing purposes with the Blacksmith project. See the Blacksmith readme for details.
Contributing
Contributions are welcome - see CONTRIBUTING.md.
License
Released under the MIT License.
Original copyright © Igor Kapkov.