NeoFaker.Person (neo_faker v0.11.0)

View Source

Functions for generating person-related information.

This module provides utilities 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".

Options

The accepted options are:

  • :locale - Specifies the locale to use.

Values for option :locale can be:

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

Examples

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

iex> NeoFaker.Person.binary_gender(locale: :id_id)
"Perempuan"

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:

  • :sex - Specifies the sex of the generated name.
  • :locale - Specifies the locale to use.

Values for option :sex can be:

  • :unisex - Generates a random unisex name (default).
  • :female - Generates a random female name.
  • :male - Generates a random male 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(sex: :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:

  • :unisex - 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 the same way as first_name/1. See first_name/1 for more details.

middle_name(opts \\ [])

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

Generates a random middle name.

This function behaves the same way as first_name/1. See first_name/1 for more details.

non_binary_gender(opts \\ [])

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

Generates a random non-binary gender.

This function behaves the same way as binary_gender/1. See binary_gender/1 for more details.

prefix(opts \\ [])

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

Generates a random name prefix.

Returns a name prefix, such as "Mr.", "Ms.", "Dr.", etc.

Options

The accepted options are:

  • :locale - Specifies the locale to use.

Values for option :locale can be:

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

Examples

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

iex> NeoFaker.Person.prefix(locale: :id_id)
"Tn."

short_binary_gender(opts \\ [])

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

Generates a random short binary gender.

This function behaves the same way as binary_gender/1. See binary_gender/1 for more details.

suffix(opts \\ [])

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

Generates a random name suffix.

This function behaves the same way as prefix/1. See prefix/1 for more details.