Current section
Files
Jump to
Current section
Files
lib/pages/cheat.cheatmd
# Cheat Sheet
A quick reference for the most commonly used random data generator functions.
## [App](`NeoFaker.App`)
{: .col-2}
### [`author(opts \\ [])`](`NeoFaker.App.author/1`)
```elixir
iex> NeoFaker.App.author()
"José Valim"
```
### [`description(opts \\ [])`](`NeoFaker.App.description/1`)
```elixir
iex> NeoFaker.App.description()
"Elixir library for generating fake data in tests and development."
iex> NeoFaker.App.description(locale: :id_id)
"Pustaka Elixir untuk menghasilkan data palsu dalam pengujian dan pengembangan."
```
### [`license()`](`NeoFaker.App.license/0`)
```elixir
iex> NeoFaker.App.license()
"MIT License"
```
### [`name(opts \\ [])`](`NeoFaker.App.name/1`)
```elixir
iex> NeoFaker.App.name()
"Neo Faker"
iex> NeoFaker.App.name(style: :camel_case)
"neoFaker"
iex> NeoFaker.App.name(locale: :id_id)
"Garuda Web"
```
### [`semver(opts \\ [])`](`NeoFaker.App.semver/1`)
```elixir
iex> NeoFaker.App.semver()
"1.2.3"
iex> NeoFaker.App.semver(type: :pre_release)
"1.2.3-beta.1"
iex> NeoFaker.App.semver(type: :build)
"1.2.3+20250325"
iex> NeoFaker.App.semver(type: :pre_release_build)
"1.2.3-rc.1+20250325"
```
### [`version()`](`NeoFaker.App.version/0`)
```elixir
iex> NeoFaker.App.version()
"1.2"
```
## [Blood](`NeoFaker.Blood`)
{: .col-2}
### [`group()`](`NeoFaker.Blood.group/0`)
```elixir
iex> NeoFaker.Blood.group()
"B+"
```
### [`type()`](`NeoFaker.Blood.type/0`)
```elixir
iex> NeoFaker.Blood.type()
"B"
```
## [Boolean](`NeoFaker.Boolean`)
{: .col-1}
### [`boolean(true_ratio \\ 50, opts \\ [])`](`NeoFaker.Boolean.boolean/2`)
```elixir
iex> NeoFaker.Boolean.boolean()
false
iex> NeoFaker.Boolean.boolean(75)
true
iex> NeoFaker.Boolean.boolean(75, integer: true)
1
```
## [Color](`NeoFaker.Color`)
{: .col-2}
### [`cmyk(opts \\ [])`](`NeoFaker.Color.cmyk/1`)
```elixir
iex> NeoFaker.Color.cmyk()
{0, 25, 50, 100}
iex> NeoFaker.Color.cmyk(format: :w3c)
"cmyk(0%, 25%, 50%, 100%)"
```
`NeoFaker.Color.hsl/1`, `NeoFaker.Color.hsla/1`, `NeoFaker.Color.rgb/1` and
`NeoFaker.Color.rgba/1` follow the same pattern, returning their respective color values in tuples
or formatted strings.
### [`hex(opts \\ [])`](`NeoFaker.Color.hex/1`)
```elixir
iex> NeoFaker.Color.hex()
"#613583"
iex> NeoFaker.Color.hex(format: :three_digit)
"#365"
```
### [`keyword(opts \\ [])`](`NeoFaker.Color.keyword/1`)
```elixir
iex> NeoFaker.Color.keyword()
"blueviolet"
iex> NeoFaker.Color.keyword(category: :basic)
"purple"
iex> NeoFaker.Color.keyword(locale: :id_id)
"ungu"
```
## [Crypto](`NeoFaker.Crypto`)
{: .col-1}
### [`md5(opts \\ [])`](`NeoFaker.Crypto.md5/1`)
```elixir
iex> NeoFaker.Crypto.md5()
"afc4c626c55e4166421d82732163857d"
iex> NeoFaker.Crypto.md5(case: :upper)
"AFC4C626C55E4166421D82732163857D"
```
`NeoFaker.Crypto.sha1/1` and `NeoFaker.Crypto.sha256/1` follow the same pattern, generating their
respective hash types with the same formatting options.
## [Date](`NeoFaker.Date`)
{: .col-2}
### [`add(range \\ -365..365, opts \\ [])`](`NeoFaker.Date.add/2`)
```elixir
iex> NeoFaker.Date.add()
~D[2025-03-25]
iex> NeoFaker.Date.add(0..31)
~D[2025-03-30]
iex> NeoFaker.Date.add(0..31, format: :iso8601)
"2025-03-25"
```
### [`between(start \\ ~D[1970-01-01], finish \\ NaiveDateTime.to_date(NaiveDateTime.local_now()), opts \\ [])`](`NeoFaker.Date.between/3`)
```elixir
iex> NeoFaker.Date.between()
~D[2025-03-25]
iex> NeoFaker.Date.between(~D[2020-01-01], ~D[2025-01-01])
~D[2022-08-17]
iex> NeoFaker.Date.between(~D[2025-03-25], ~D[2025-03-25], format: :iso8601)
"2025-03-25"
```
### [`birthday(min_age \\ 18, max_age \\ 65, opts \\ [])`](`NeoFaker.Date.birthday/3`)
```elixir
iex> NeoFaker.Date.birthday()
~D[1997-01-02]
iex> NeoFaker.Date.birthday(18, 65)
~D[1998-03-04]
iex> NeoFaker.Date.birthday(18, 65, format: :iso8601)
"1999-05-06"
```
## [Gravatar](`NeoFaker.Gravatar`)
{: .col-1}
### [`display(email \\ nil, opts \\ [])`](`NeoFaker.Gravatar.display/2`)
```elixir
iex> NeoFaker.Gravatar.display()
"https://gravatar.com/avatar/<hashed_email>?d=identicon&s=80"
iex> NeoFaker.Gravatar.display("john.doe@example.com")
"https://gravatar.com/avatar/<hashed_email>?d=identicon&s=80"
iex> NeoFaker.Gravatar.display("john.doe@example.com", size: 100)
"https://gravatar.com/avatar/<hashed_email>?d=identicon&s=100"
iex> NeoFaker.Gravatar.display("john.doe@example.com", fallback: :monsterid)
"https://gravatar.com/avatar/<hashed_email>?d=monsterid&s=80"
```
## [HTTP](`NeoFaker.Http`)
{: .col-2}
### [`referrer_policy()`](`NeoFaker.Http.referrer_policy/0`)
```elixir
iex> NeoFaker.Http.referrer_policy()
"no-referrer"
```
### [`request_method()`](`NeoFaker.Http.request_method/0`)
```elixir
iex> NeoFaker.Http.request_method()
"GET"
```
### [`status_code(opts \\ [])`](`NeoFaker.Http.status_code/1`)
```elixir
iex> NeoFaker.Http.status_code()
"200 OK"
iex> NeoFaker.Http.status_code(type: :simple)
"200"
iex> NeoFaker.Http.status_code(group: :client_error)
"404 Not Found"
```
### [`user_agent(opts \\ [])`](`NeoFaker.Http.user_agent/1`)
```elixir
iex> NeoFaker.Http.user_agent()
"Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0"
iex> NeoFaker.Http.user_agent(type: :browser)
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0"
iex> NeoFaker.Http.user_agent(type: :crawler)
"Mozilla/5.0 (compatible; Google-InspectionTool/1.0)"
```
## [Lorem](`NeoFaker.Lorem`)
{: .col-1}
### [`sentence(opts \\ [])`](`NeoFaker.Lorem.sentence/1`)
```elixir
iex> NeoFaker.Lorem.paragraph()
"Suspendisse ac justo venenatis, tincidunt sapien nec, accumsan augue. Vestibulum urna
risus, egestas ut ultrices non, aliquet eget massa. Mauris id diam eget augue sagittis
convallis sit amet nec diam. Morbi ut blandit est, et placerat neque."
iex> NeoFaker.Lorem.paragraph(type: "meditations")
"Do the things external which fall upon thee distract thee? Give thyself time to learn
something new and good, and cease to be whirled around. But then thou must also avoid being
carried about the other way. For those too are triflers who have wearied themselves in life
by their activity, and yet have no object to which to direct every movement, and, in a word,
all their thoughts."
```
`NeoFaker.Lorem.sentence/1` and `NeoFaker.Lorem.word/1` follow the same pattern, supporting the
same types and format options but generate different text lengths.
## [Number](`NeoFaker.Number`)
{: .col-2}
### [`between(min \\ 0, max \\ 100)`](`NeoFaker.Number.between/2`)
```elixir
iex> NeoFaker.Number.between()
27
iex> NeoFaker.Number.between(1, 100)
28
iex> NeoFaker.Number.between(20, 100.0)
29.481745280074264
iex> NeoFaker.Number.between(10.0, 100.0)
29.481745280074264
```
### [`digit()`](`NeoFaker.Number.digit/0`)
```elixir
iex> NeoFaker.Number.digit()
5
```
### [`float(left_digit \\ 10..100, right_digit \\ 10_000..100_000)`](`NeoFaker.Number.float/2`)
```elixir
iex> NeoFaker.Number.float()
30.94372
iex> NeoFaker.Number.float(1..9, 10..90)
1.44
```
## [Person](`NeoFaker.Person`)
{: .col-2}
### [`age(min \\ 0, max \\ 120)`](`NeoFaker.Person.age/2`)
```elixir
iex> NeoFaker.Person.age()
44
iex> NeoFaker.Person.age(7, 44)
27
```
### [`binary_gender(opts \\ [])`](`NeoFaker.Person.binary_gender/1`)
```elixir
iex> NeoFaker.Person.binary_gender()
"Male"
iex> NeoFaker.Person.binary_gender(locale: :id_id)
"Perempuan"
```
`NeoFaker.Person.non_binary_gender/1` and `NeoFaker.Person.short_binary_gender/1` accept the same
options and follow the same pattern, but generate different gender values.
### [`first_name(opts \\ [])`](`NeoFaker.Person.first_name/1`)
```elixir
iex> NeoFaker.Person.first_name()
"Julia"
iex> NeoFaker.Person.first_name(sex: :male)
"José"
iex> NeoFaker.Person.first_name(locale: :id_id)
"Jaka"
```
`NeoFaker.Person.middle_name/1` and `NeoFaker.Person.last_name/1` accept the same options and
follow the same pattern, but generate middle or last names respectively.
### [`full_name(opts \\ [])`](`NeoFaker.Person.full_name/1`)
```elixir
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"
```
### [`prefix(opts \\ [])`](`NeoFaker.Person.prefix/1`)
```elixir
iex> NeoFaker.Person.prefix()
"Mr."
iex> NeoFaker.Person.prefix(locale: :id_id)
"Tn."
```
`NeoFaker.Person.suffix/1` accepts the same options and follows the same pattern, but generates
name suffixes instead of prefixes.
## [Text](`NeoFaker.Text`)
{: .col-2}
### [`character(opts \\ [])`](`NeoFaker.Text.character/1`)
```elixir
iex> NeoFaker.Text.character()
"a"
iex> NeoFaker.Text.character(type: :digit)
"0"
```
### [`characters(number \\ 11, opts \\ [])`](`NeoFaker.Text.characters/2`)
```elixir
iex> NeoFaker.Text.characters()
"XfELJU1mRMg"
iex> NeoFaker.Text.characters(20, type: :alphabet_upper)
"BVAJHRGSCEVJFNYSWCJE"
```
### [`emoji(opts \\ [])`](`NeoFaker.Text.emoji/1`)
```elixir
iex> NeoFaker.Text.emoji()
"✨"
iex> NeoFaker.Text.emoji(category: :activities)
"🎉"
```
### [`word()`](`NeoFaker.Text.word/0`)
```elixir
iex> NeoFaker.Text.word()
"computer"
```
## [Time](`NeoFaker.Time`)
{: .col-2}
### [`add(range \\ -24..24, opts \\ [])`](`NeoFaker.Time.add/1`)
```elixir
iex> NeoFaker.Time.add()
~T[15:22:10]
iex> NeoFaker.Time.add(-2..2, unit: :minute)
~T[07:23:10]
iex> NeoFaker.Time.add(0..10, format: :iso8601)
"15:22:10"
```
### [`between(start \\ ~T[00:00:00], finish \\ ~T[23:59:59], opts \\ [])`](`NeoFaker.Time.between/1`)
```elixir
iex> NeoFaker.Time.between()
~T[15:22:10]
iex> NeoFaker.Time.between(~T[00:00:00], ~T[23:59:59])
~T[19:30:11]
iex> NeoFaker.Time.between(~T[00:00:00], ~T[23:59:59], format: :iso8601)
"15:22:10"
```