Bankster v0.3.0 Bankster.Iban View Source

Provides some IBAN related functions.

Link to this section Summary

Functions

Returns the BBAN of the given IBAN

Returns the country code of the given IBAN

Formats and returns a given IBAN in compact format

Formats and returns a given IBAN in pretty format

Returns the size/length of the given IBAN

Validates a string whether it’s a valid IBAN and returns a boolen value

Validates a string whether it’s a valid IBAN an returns an error tuple on invalid data

Link to this section Functions

Returns the BBAN of the given IBAN.

Examples

iex> Bankster.Iban.bban("DK8387188644726815")
"83"
Link to this function country_code(iban) View Source
country_code(String.t()) :: String.t()

Returns the country code of the given IBAN.

Examples

iex> Bankster.Iban.country_code("DK8387188644726815")
"DK"
Link to this function format_compact(iban) View Source
format_compact(String.t()) :: String.t()

Formats and returns a given IBAN in compact format.

Examples

iex> Bankster.Iban.format_compact("DK8     38 7188 64472     6815   ")
"DK8387188644726815"
Link to this function format_pretty(iban) View Source
format_pretty(String.t()) :: String.t()

Formats and returns a given IBAN in pretty format.

Examples

iex> Bankster.Iban.format_pretty("DK8387188644726815")
"DK838 7188 64472 6815"

Returns the size/length of the given IBAN.

Examples

iex> Bankster.Iban.size("DK 8387   188644     726815")
18

Validates a string whether it’s a valid IBAN and returns a boolen value.

Examples

iex> Bankster.Iban.valid?("INVALIDIBAN")
false

iex> Bankster.Iban.valid?("DK8387188644726815")
true
Link to this function validate(iban) View Source
validate(String.t()) :: {:ok, String.t()} | {:error, Atom.t()}

Validates a string whether it’s a valid IBAN an returns an error tuple on invalid data.

Examples

iex> Bankster.Iban.validate("INVALIDIBAN")
{:error, :invalid_country}

iex> Bankster.Iban.validate("DK838718234242342348644726815")
{:error, :invalid_length}

iex> Bankster.Iban.validate("DK8387188644726815")
{:ok, "DK8387188644726815"}