Helps validating IBAN account numbers and BIC numbers. Thats all for the great language Elixir.
The package can be installed as Hex package:
- Add bankster to your list of dependencies in
mix.exs
:
def deps do
[{:bankster, "~> 0.2.2"}]
end
- Run
mix deps.get
to fetch the package from hex
You can either use Bankster.iban_valid?/1
or Bankster.Iban.valid?/1
to validate IBANs.
iex> Bankster.iban_valid?("NOTVALID")
false
iex> Bankster.Iban.valid?("NOTVALID")
false
Beside the boolean validation function, Bankster offers a validation function which returns the corresponding error.
Like the other validation, you can use Bankster.iban_validate/1
or Bankster.Iban.validate/1
to validate IBANs.
iex> Bankster.iban_validate("NOTVALID")
{:error, :invalid_country}
iex> Bankster.Iban.validate("DK8387188644726815223423423423423423423")
{:error, :invalid_length}
iex> Bankster.Iban.validate("DK83 8718 8644 7268 15")
{:ok, "DK8387188644726815"}
Validating BICs works the same way as already shown for IBANs.
So you can either use Bankster.bic_valid?/1
or Bankster.Bic.valid?/1
to validate BICs.
iex> Bankster.bic_valid?("NOTVALID")
false
iex> Bankster.Bic.valid?("NOTVALID")
false
Bankster source code is released under MIT License. Check LICENSE file for more information.