View Source ElixirCLRut.Validations (ElixirCLRUT v1.0.3)
Stores different validation functions
Link to this section Summary
Functions
Optional validation. Validates Rut is above or equal to 1 million. To avoid probably dead people.
Optional validation. Validates Rut is below or equal to 100 million. To avoid probably non existing people.
Receives a Token struct and validates checkdigit with lastdigit. If they are different it will add :wrong_checkdigit to the errors list. iex> has_valid_checkdigit(ElixirCLRut.Token.from(ElixirCLRut.from("20.961605-C"))) %ElixirCLRut.Token{errors: [:wrong_checkdigit], valid?: false, from: %ElixirCLRut.Struct{from: "20.961605-C", checkdigit: "0", lastdigit: "5", lastchar: nil, normalized: [2, 0, 9, 6, 1, 6, 0], normalized_with_checkdigit: [2, 0, 9, 6, 1, 6, 0, 5], includes_checkdigit?: true, dashed?: true}}
Optional validation. Receives a Token struct and validates the normalized length is above or equal to the given length. Defaults to length 2.
Optional validation. Receives a Token struct and validates that all chars are not jut zeroes.
Receives a Token struct and counts the normalized array, if it's empty it will add :value_is_empty to the errors list. iex> not_empty(ElixirCLRut.Token.from(ElixirCLRut.from("abc"))) %ElixirCLRut.Token{errors: [:value_is_empty], from: %ElixirCLRut.Struct{from: "abc", checkdigit: :error, lastdigit: "", lastchar: nil, normalized: [], normalized_with_checkdigit: [], includes_checkdigit?: true, dashed?: false}, valid?: false}
Link to this section Functions
Optional validation. Validates Rut is above or equal to 1 million. To avoid probably dead people.
- since: "1.0.2"
example
Example
iex> (ElixirCLRut.valid("1.000.000-9") |> equal_or_above_1M()).valid? true
Optional validation. Validates Rut is below or equal to 100 million. To avoid probably non existing people.
- since: "1.0.2"
example
Example
iex> (ElixirCLRut.valid("100.000.000-7") |> equal_or_below_100M()).valid? true
Receives a Token struct and validates checkdigit with lastdigit. If they are different it will add :wrong_checkdigit to the errors list. iex> has_valid_checkdigit(ElixirCLRut.Token.from(ElixirCLRut.from("20.961605-C"))) %ElixirCLRut.Token{errors: [:wrong_checkdigit], valid?: false, from: %ElixirCLRut.Struct{from: "20.961605-C", checkdigit: "0", lastdigit: "5", lastchar: nil, normalized: [2, 0, 9, 6, 1, 6, 0], normalized_with_checkdigit: [2, 0, 9, 6, 1, 6, 0, 5], includes_checkdigit?: true, dashed?: true}}
Optional validation. Receives a Token struct and validates the normalized length is above or equal to the given length. Defaults to length 2.
example
Example
iex> (ElixirCLRut.valid("00-0") |> ElixirCLRut.Validations.length()).valid?
true
iex> (ElixirCLRut.valid("00-0") |> ElixirCLRut.Validations.length(3)).valid?
false
Optional validation. Receives a Token struct and validates that all chars are not jut zeroes.
example
Example
iex> (ElixirCLRut.valid("00000000-0") |> not_all_zeroes()).valid?
false
iex> (ElixirCLRut.valid("00000001-9") |> not_all_zeroes()).valid?
true
Receives a Token struct and counts the normalized array, if it's empty it will add :value_is_empty to the errors list. iex> not_empty(ElixirCLRut.Token.from(ElixirCLRut.from("abc"))) %ElixirCLRut.Token{errors: [:value_is_empty], from: %ElixirCLRut.Struct{from: "abc", checkdigit: :error, lastdigit: "", lastchar: nil, normalized: [], normalized_with_checkdigit: [], includes_checkdigit?: true, dashed?: false}, valid?: false}