Cheat Sheet

View Source

A quick reference for the most commonly used random data generator functions.

App

author(opts \\ [])

iex> NeoFaker.App.author()
"José Valim"

description(opts \\ [])

iex> NeoFaker.App.description()
"Elixir library for generating fake data in tests and development."

license()

iex> NeoFaker.App.license()
"MIT License"

name(opts \\ [])

iex> NeoFaker.App.name()
"Neo Faker"

iex> NeoFaker.App.name(style: :camel_case)
"neoFaker"

semver(opts \\ [])

iex> NeoFaker.App.semver()
"1.2.3"

iex> NeoFaker.App.semver(type: :pre_release)
"1.2.3-beta.1"

version()

iex> NeoFaker.App.version()
"1.2"

Blood

group()

iex> NeoFaker.Blood.group()
"B+"

type()

iex> NeoFaker.Blood.type()
"B"

Boolean

boolean(true_ratio \\ 50, opts \\ [])

iex> NeoFaker.Boolean.boolean()
false

iex> NeoFaker.Boolean.boolean(75)
true

iex> NeoFaker.Boolean.boolean(75, integer: true)
1

Crypto

md5(opts \\ [])

iex> NeoFaker.Crypto.md5()
"e35cb102765cfc56df21ba4c16e6a636"

iex> NeoFaker.Crypto.md5(case: :upper)
"E35CB102765CFC56DF21BA4C16E6A636"

NeoFaker.Crypto.sha1/1 and NeoFaker.Crypto.sha256/1 behave similarly.

Gravatar

display(email \\ nil, opts \\ [])

iex> NeoFaker.Gravatar.display()
"https://gravatar.com/avatar/<hashed_email>?d=identicon&s=80"

iex> NeoFaker.Gravatar.display("john.doe@example.com", fallback: :monsterid)
"https://gravatar.com/avatar/<hashed_email>?d=monsterid&s=80"

Person

age(min \\ 0, max \\ 120)

iex> NeoFaker.Person.age()
44

iex> NeoFaker.Person.age(7..44)
27

binary_gender()

iex> NeoFaker.Person.binary_gender()
"Male"

first_name(opts \\ [])

iex> NeoFaker.Person.first_name()
"Julia"

iex> NeoFaker.Person.first_name(type: :male)
"José"

NeoFaker.Person.middle_name/1 and NeoFaker.Person.last_name/1 behave similarly.

full_name(opts \\ [])

iex> NeoFaker.Person.full_name()
"Abigail Bethany Crawford"

iex> NeoFaker.Person.full_name(sex: :male)
"Daniel Edward Fisher"

iex> NeoFaker.Person.full_name(middle_name: false)
"Gabriella Harrison"

non_binary_gender(opts \\ [])

iex> NeoFaker.Person.non_binary_gender()
"Agender"

prefix(opts \\ [])

iex> NeoFaker.Person.prefix()
"Mr."

short_binary_gender(opts \\ [])

iex> NeoFaker.Person.short_binary_gender()
"F"

suffix(opts \\ [])

iex> NeoFaker.Person.suffix()
"IV"