View Source ElixirCLRut.Validations (ElixirCLRUT v1.0.0)

Stores different validation functions

Link to this section Summary

Functions

Receives a Token struct and validates checkdigit with lastdigit. If they are different it will add :wrong_checkdigit to the errors list.

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.

Link to this section Functions

Link to this function

has_valid_checkdigit(token)

View Source (since 1.0.0)
@spec has_valid_checkdigit(struct()) :: struct()

Receives a Token struct and validates checkdigit with lastdigit. If they are different it will add :wrong_checkdigit to the errors list.

Link to this function

length(token, length \\ 2)

View Source (since 1.0.0)
@spec length(
  struct(),
  integer()
) :: struct()

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.validate("00-0") |> ElixirCLRut.Validations.length()).valid?
true

iex> (ElixirCLRut.validate("00-0") |> ElixirCLRut.Validations.length(3)).valid?
false
Link to this function

not_all_zeroes(token)

View Source (since 1.0.0)
@spec not_all_zeroes(struct()) :: struct()

Optional validation. Receives a Token struct and validates that all chars are not jut zeroes.

example

Example

iex> (ElixirCLRut.validate("00000000-0") |> not_all_zeroes()).valid?
false

iex> (ElixirCLRut.validate("00000001-9") |> not_all_zeroes()).valid?
true
Link to this function

not_empty(token)

View Source (since 1.0.0)
@spec not_empty(struct()) :: struct()

Receives a Token struct and counts the normalized array, if it's empty it will add :value_is_empty to the errors list.