fsanggang / nz_bank_account_validator

An Elixir library to validate NZ bank account numbers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NzBankAccountValidator

Build Status Hex.pm

Validator for NZ bank accounts.

Examples

$ iex -S mix
> NzBankAccountValidator.is_valid?("31-2800-0320871-032")
{:ok, true}

iex> NzBankAccountValidator.is_valid?("01-3333-0068389-00")
{:error, "Invalid bank_branch: 3333"}

Options

There is a separator between each component of a bank account number (defaults to -).

$ iex -S mix
> NzBankAccountValidator.is_valid?("31-2800-0320871-032")
{:ok, true}

> NzBankAccountValidator.is_valid?("31 2800 0320871 032", " ")
{:ok, true}

Installation

Add nz_bank_account_validator to your list of dependencies in mix.exs:

def deps do
  [
    {:nz_bank_account_validator, "~> 1.0.0"}
  ]
end

Don’t forget to update your dependencies.

$ mix deps.get

Links

Implementation is based off https://www.ird.govt.nz/resources/d/8/d8e49dce-1bda-4875-8acf-9ebf908c6e17/rwt-nrwt-spec-2014.pdf.

About

An Elixir library to validate NZ bank account numbers

License:MIT License


Languages

Language:Elixir 100.0%