View Source HumanName (human_name v0.6.1)
Documentation for HumanName.
Summary
Functions
Performs a comparison of two full names to determine if they are potentially consistent with each other.
Returns the combined initials for the first name (given name) and last name (surname).
Returns the initial for the first name (given name).
Returns the initial for the first name (given name) and the full last name (surname).
Returns just the formatted first name (given name).
Returns just the formatted last name (surname).
Returns just the formatted last name (surname).
Returns the middle initial(s) for a provided full name.
Returns the inferred middle name for a provided full name.
Returns a formatted version of just the first (given) and last (surname) names.
Returns a formatted version of the entire name.
Functions
Performs a comparison of two full names to determine if they are potentially consistent with each other.
It is important to take into account the nuance of this consistency by reading the Defining “consistency” section of the rust library documentation.
Example
iex> HumanName.consistent_with?("Jimmy H Jenkins", "Jim Jenkins")
{:ok, true}
iex> HumanName.consistent_with?("John Doe", "Johnny J. Doe")
{:ok, true}
iex> HumanName.consistent_with?("Dr. Alibaster Cornelius Juniper III", "Alibaster Juniper")
{:ok, true}
iex> HumanName.consistent_with?("Jane Doe", "J. Doe")
{:ok, true}
iex> HumanName.consistent_with?("Dr. Alibaster Cornelius Juniper III", "Jimmy H Jenkins")
{:ok, false}
iex> HumanName.consistent_with?(12345, "John Doe")
{:error, "No valid names found"}
iex> HumanName.consistent_with?("fj20i424j", "thisisnotavalidname")
{:error, "No valid name_one found"}
iex> HumanName.consistent_with?("Jimmy H Jenkins", "1234")
{:error, "No valid name_two found"}
iex> HumanName.consistent_with?(nil, nil)
{:error, "No valid names found"}
Returns the combined initials for the first name (given name) and last name (surname).
Example
iex> HumanName.first_and_last_initials("Jimmy H Jenkins")
{:ok, "JJ"}
iex> HumanName.first_and_last_initials("Dr. Alibaster Cornelius Juniper III")
{:ok, "AJ"}
iex> HumanName.first_and_last_initials("Jane Doe")
{:ok, "JD"}
iex> HumanName.first_and_last_initials("")
{:error, "No valid name found"}
Returns the initial for the first name (given name).
Example
iex> HumanName.first_initial("Jimmy H Jenkins")
{:ok, "J"}
iex> HumanName.first_initial("Dr. Alibaster Cornelius Juniper III")
{:ok, "A"}
iex> HumanName.first_initial("Jane Doe")
{:ok, "J"}
iex> HumanName.first_initial(12345)
{:error, "No valid name found"}
iex> HumanName.first_initial("")
{:error, "No valid name found"}
iex> HumanName.first_initial(nil)
{:error, "No valid name found"}
Returns the initial for the first name (given name) and the full last name (surname).
Example
iex> HumanName.first_initial_last("Jimmy H Jenkins")
{:ok, "J. Jenkins"}
iex> HumanName.first_initial_last("Dr. Alibaster Cornelius Juniper III")
{:ok, "A. Juniper"}
iex> HumanName.first_initial_last("Jane Doe")
{:ok, "J. Doe"}
iex> HumanName.first_initial_last("")
{:error, "No valid name found"}
Returns just the formatted first name (given name).
Example
iex> HumanName.first_name("Jimmy H Jenkins")
{:ok, "Jimmy"}
iex> HumanName.first_name("Dr. Alibaster Cornelius Juniper III")
{:ok, "Alibaster"}
iex> HumanName.first_name("Jane Doe")
{:ok, "Jane"}
iex> HumanName.first_name("")
{:error, "No valid name found"}
Returns just the formatted last name (surname).
Example
iex> HumanName.last_initial("Jimmy H Jenkins")
{:ok, "J"}
iex> HumanName.last_initial("Dr. Alibaster Cornelius Juniper III")
{:ok, "J"}
iex> HumanName.last_initial("Jane Doe")
{:ok, "D"}
iex> HumanName.last_initial("")
{:error, "No valid name found"}
Returns just the formatted last name (surname).
Example
iex> HumanName.last_name("Jimmy H Jenkins")
{:ok, "Jenkins"}
iex> HumanName.last_name("Dr. Alibaster Cornelius Juniper III")
{:ok, "Juniper"}
iex> HumanName.last_name("Jane Doe")
{:ok, "Doe"}
iex> HumanName.last_name("")
{:error, "No valid name found"}
Returns the middle initial(s) for a provided full name.
Example
iex> HumanName.middle_initials("Dr. Alibaster Cornelius Juniper III")
{:ok, "C"}
iex> HumanName.middle_initials("Jimmy H Jenkins")
{:ok, "H"}
iex> HumanName.middle_initials("Jane Dorothy Doe")
{:ok, "D"}
iex> HumanName.middle_initials("Jimmy Jenkins")
{:error, "No middle initials found"}
iex> HumanName.middle_initials("")
{:error, "No valid name found"}
Returns the inferred middle name for a provided full name.
Example
iex> HumanName.middle_name("Dr. Alibaster Cornelius Juniper III")
{:ok, "Cornelius"}
iex> HumanName.middle_name("Jane Dorothy Doe")
{:ok, "Dorothy"}
iex> HumanName.middle_name("Jimmy H Jenkins")
{:error, "No middle name found"}
iex> HumanName.middle_name("")
{:error, "No valid name found"}
Returns a formatted version of just the first (given) and last (surname) names.
Example
iex> HumanName.normalize("Jimmy H Jenkins")
{:ok, "Jimmy Jenkins"}
iex> HumanName.normalize("Dr. Alibaster Cornelius Juniper III")
{:ok, "Alibaster Juniper"}
iex> HumanName.normalize("fred mccalister ")
{:ok, "Fred McCalister"}
iex> HumanName.normalize("")
{:error, "No valid name found"}
Returns a formatted version of the entire name.
Example
iex> HumanName.normalize_full("JIMMY H JENKINS")
{:ok, "Jimmy H. Jenkins"}
iex> HumanName.normalize_full("Dr. Alibaster Cornelius Juniper III")
{:ok, "Alibaster Cornelius Juniper, III"}
iex> HumanName.normalize_full("fred mccalister ")
{:ok, "Fred McCalister"}
iex> HumanName.normalize_full("")
{:error, "No valid name found"}