View Source AbaValidator.Utils (ABA Validator v1.0.0)

Documentation for AbaValidator.Utils.

Link to this section Summary

Functions

Checks if the length of the string matches to the defined 'n' value

Checks if the string is empty

Checks if the string is a valid bsb format

Checks if the date string is valid. If a year prefix is not provided then it will consider it as first two digits of the current year

Link to this section Functions

Link to this function

correct_length?(entry, n \\ 0)

View Source
@spec correct_length?(String.t(), integer()) :: :error | boolean()

Checks if the length of the string matches to the defined 'n' value

examples

Examples

iex> AbaValidator.Utils.correct_length?(1)
:error

iex> AbaValidator.Utils.correct_length?("", false)
:error

iex> AbaValidator.Utils.correct_length?("11")
false

iex> AbaValidator.Utils.correct_length?("01",2)
true

iex> AbaValidator.Utils.correct_length?(" " ,1 )
true
@spec string_empty?(String.t()) :: :error | boolean()

Checks if the string is empty

examples

Examples

iex> AbaValidator.Utils.string_empty?(1)
:error

iex> AbaValidator.Utils.string_empty?("11")
false

iex> AbaValidator.Utils.string_empty?(" " )
true
@spec valid_bsb?(String.t()) :: boolean()

Checks if the string is a valid bsb format

examples

Examples

iex> AbaValidator.Utils.valid_bsb?(1)
false

iex> AbaValidator.Utils.valid_bsb?("123 231")
false

iex> AbaValidator.Utils.valid_bsb?("123-2a1")
false

iex> AbaValidator.Utils.valid_bsb?("11")
false

iex> AbaValidator.Utils.valid_bsb?("123-312" )
true
Link to this function

valid_date?(date, year_prefix \\ "")

View Source
@spec valid_date?(String.t(), String.t()) :: :error | boolean()

Checks if the date string is valid. If a year prefix is not provided then it will consider it as first two digits of the current year

examples

Examples

iex> AbaValidator.Utils.valid_date?(1)
:error

iex> AbaValidator.Utils.valid_date?("11")
:error

iex> AbaValidator.Utils.valid_date?(" ")
:error

iex> AbaValidator.Utils.valid_date?("")
:error

iex> AbaValidator.Utils.valid_date?("123231")
false

iex> AbaValidator.Utils.valid_date?("120423")
true