View Source ElixirCLRut (ElixirCLRUT v1.0.1)
A module that helps with validation and formatting of chilean RUT/RUN identifiers. Made by the Elixir Chile Community.
Link to this section Summary
Functions
Formats a string or Rut struct with the Rut format.
When given a string it will return an ElixirCLRut.Struct
Performs a simple validation and returns the boolean result. true if is valid.
Executes the rut validations.
Link to this section Functions
Link to this function
format(input, options \\ [dashed?: false, separator: "."])
View Source (since 1.0.1)Formats a string or Rut struct with the Rut format.
examples
Examples
iex> format("1")
"1-9"
iex> format("63009482", true)
"6.300.948-2"
iex> format("63009482", dashed?: true, separator: ",")
"6,300,948-2"
When given a string it will return an ElixirCLRut.Struct
example
Example
iex> from("1-9")
%ElixirCLRut.Struct{checkdigit: "9", dashed?: true, from: "1-9", lastdigit: "9", normalized: [1], normalized_with_checkdigit: [1, 9]}
Performs a simple validation and returns the boolean result. true if is valid.
examples
Examples
iex> valid?("1")
true
iex> valid?("6300948-1")
false
iex> valid?(from("6300948-1"))
false
Executes the rut validations.
examples
Examples
iex> validate("1").valid?
true
iex> validate("6300948-1").valid?
false