NeoFaker.Person (neo_faker v0.14.0)

Copy Markdown View Source

Functions for generating person-related information.

Provides utilities to generate random personal details including first, middle, and last names, full names, prefixes, suffixes, ages, and genders with support for multiple locales and sex options.

Summary

Functions

Generates a random age as a non-negative integer.

Generates a random binary gender.

Generates a random first name.

Generates a random full name.

Generates a random full name with optional prefix and/or suffix.

Generates a random last name.

Generates a random middle name.

Generates a random non-binary gender identity string.

Generates a random name prefix such as "Mr.", "Ms.", or "Dr.".

Generates a random short binary gender such as "M" or "F".

Generates a random name suffix such as "Jr.", "Sr.", or "III".

Functions

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

(since 0.6.0)

Generates a random age as a non-negative integer.

Parameters

  • min - Minimum age, inclusive. Defaults to 0.
  • max - Maximum age, inclusive. Defaults to 120.

Examples

iex> NeoFaker.Person.age()
44

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

iex> NeoFaker.Person.age(18, 65)
35

binary_gender(opts \\ [])

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

Generates a random binary gender.

Returns either "Male" or "Female" in the configured locale.

Options

  • :locale - Locale to use. Defaults to the application's configured locale.

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.

Options

  • :sex - Sex of the name. One of :unisex (default), :female, or :male.
  • :locale - Locale to use. Defaults to the application's configured locale.

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.

Combines a first name, an optional middle name, and a last name.

Options

  • :sex - Sex of the name. One of :unisex (default), :female, or :male.
  • :locale - Locale to use. Defaults to the application's configured locale.
  • :middle_name - Whether to include a middle name. Defaults to true.

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"

iex> NeoFaker.Person.full_name(sex: :female, locale: :id_id, middle_name: false)
"Siti Nurhaliza"

full_name_with_title(opts \\ [])

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

Generates a random full name with optional prefix and/or suffix.

Delegates to full_name/1 and wraps the result with the requested title parts.

Options

  • :sex - Sex of the name. One of :unisex (default), :female, or :male.
  • :locale - Locale to use. Defaults to the application's configured locale.
  • :middle_name - Whether to include a middle name. Defaults to true.
  • :prefix - When true, prepends a name prefix such as "Mr." or "Dr.". Defaults to false.
  • :suffix - When true, appends a name suffix such as "Jr." or "III". Defaults to false.

Examples

iex> NeoFaker.Person.full_name_with_title(prefix: true)
"Dr. Abigail Bethany Crawford"

iex> NeoFaker.Person.full_name_with_title(suffix: true)
"Daniel Edward Fisher Jr."

iex> NeoFaker.Person.full_name_with_title(prefix: true, suffix: true, middle_name: false)
"Mr. John Smith III"

last_name(opts \\ [])

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

Generates a random last name.

Options

  • :sex - Sex of the name. One of :unisex (default), :female, or :male.
  • :locale - Locale to use. Defaults to the application's configured locale.

Examples

iex> NeoFaker.Person.last_name()
"Smith"

iex> NeoFaker.Person.last_name(sex: :male)
"Johnson"

iex> NeoFaker.Person.last_name(locale: :id_id)
"Wijaya"

middle_name(opts \\ [])

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

Generates a random middle name.

Options

  • :sex - Sex of the name. One of :unisex (default), :female, or :male.
  • :locale - Locale to use. Defaults to the application's configured locale.

Examples

iex> NeoFaker.Person.middle_name()
"Anne"

iex> NeoFaker.Person.middle_name(sex: :male)
"James"

iex> NeoFaker.Person.middle_name(locale: :id_id)
"Budi"

non_binary_gender(opts \\ [])

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

Generates a random non-binary gender identity string.

Options

  • :locale - Locale to use. Defaults to the application's configured locale.

Examples

iex> NeoFaker.Person.non_binary_gender()
"Non-binary"

iex> NeoFaker.Person.non_binary_gender(locale: :id_id)
"Non-biner"

prefix(opts \\ [])

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

Generates a random name prefix such as "Mr.", "Ms.", or "Dr.".

Options

  • :locale - Locale to use. Defaults to the application's configured locale.

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 such as "M" or "F".

Options

  • :locale - Locale to use. Defaults to the application's configured locale.

Examples

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

iex> NeoFaker.Person.short_binary_gender(locale: :id_id)
"P"

suffix(opts \\ [])

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

Generates a random name suffix such as "Jr.", "Sr.", or "III".

Options

  • :locale - Locale to use. Defaults to the application's configured locale.

Examples

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

iex> NeoFaker.Person.suffix(locale: :id_id)
"S.Kom"

iex> NeoFaker.Person.suffix(locale: :en_us)
"III"