NeoFaker.Person (neo_faker v0.7.1)

View Source

Provides functions for generating person-related information.

This module offers a variety of functions to generate random personal details, such as names, ages, and genders.

Summary

Functions

Generates a random age.

Generates a random binary gender.

Generates a random first name.

Generates a random full name.

Generates a random last name.

Generates a random middle name.

Generates a random non-binary gender.

Generates a random name prefix.

Generates a random short binary gender.

Generates a random name suffix.

Functions

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

(since 0.6.0)

Generates a random age.

The age is a non-negative integer between 0 and 120 by default.

Examples

iex> NeoFaker.Person.age()
44

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

binary_gender(opts \\ [])

(since 0.6.0)
@spec binary_gender(Keyword.t()) :: String.t()

Generates a random binary gender.

Returns either "Male" or "Female".

Examples

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

first_name(opts \\ [])

(since 0.7.0)
@spec first_name(Keyword.t()) :: String.t()

Generates a random first name.

If no options are provided, it returns a random unisex first name.

Options

The accepted options are:

  • :type - Specifies the type of name to generate.
  • :locale - Specifies the locale to use.

Values for option :type can be:

  • nil - Generates a random unisex name (default).
  • :male - Generates a random male name.
  • :female - Generates a random female name.

Values for option :locale can be:

  • nil - Uses the default locale "default".
  • "id_id" - Uses the Indonesian locale, for example.

Examples

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

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

iex> NeoFaker.Person.first_name(locale: "id_id")
"Jaka"

full_name(opts \\ [])

(since 0.7.0)
@spec full_name(Keyword.t()) :: String.t()

Generates a random full name.

If no options are provided, it returns a default random unisex full name.

Options

The accepted options are:

  • :locale - Specifies the locale to use.
  • :sex - Specifies the sex of the generated name.
  • :middle_name - Determines whether to include a middle name in the full name.

Values for option :locale can be:

  • nil - Uses the default locale "default".
  • "id_id" - Uses the Indonesian locale, for example.

Values for option :sex can be:

  • nil - Generates a random unisex name (default).
  • :male - Generates a random male name.
  • :female - Generates a random female name.

Values for option :middle_name can be:

  • true - Includes a random middle name (default).
  • false - Excludes the middle name.

Examples

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"

last_name(opts \\ [])

(since 0.7.0)
@spec last_name(Keyword.t()) :: String.t()

Generates a random last name.

This function behaves similarly to first_name/1. See first_name/1 for available options.

middle_name(opts \\ [])

(since 0.7.0)
@spec middle_name(Keyword.t()) :: String.t()

Generates a random middle name.

This function behaves similarly to first_name/1. See first_name/1 for available options.

non_binary_gender(opts \\ [])

(since 0.6.0)
@spec non_binary_gender(Keyword.t()) :: String.t()

Generates a random non-binary gender.

Returns a non-binary gender, such as "Agender", "Androgyne", "Bigender", etc.

Examples

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

prefix(opts \\ [])

(since 0.6.0)
@spec prefix(Keyword.t()) :: String.t()

Generates a random name prefix.

Examples

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

short_binary_gender(opts \\ [])

(since 0.6.0)
@spec short_binary_gender(Keyword.t()) :: String.t()

Generates a random short binary gender.

Returns either "M" or "F".

Examples

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

suffix(opts \\ [])

(since 0.7.0)
@spec suffix(Keyword.t()) :: String.t()

Generates a random name suffix.

Examples

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