View Source Bankster.Iban (Bankster v0.4.0)

Module provides some IBAN related functions.

Summary

Functions

Returns the BBAN of the given IBAN.

Returns the checksum 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.

Returns the country codes of the supported countries.

Validates whether the given country code is within the supported countries.

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.

Functions

@spec bban(binary()) :: binary()

Returns the BBAN of the given IBAN.

Examples

iex> Bankster.Iban.bban("DK8387188644726815")
"87188644726815"
@spec checksum(binary()) :: binary()

Returns the checksum of the given IBAN.

Examples

iex> Bankster.Iban.checksum("DK8387188644726815")
83
@spec country_code(binary()) :: binary()

Returns the country code of the given IBAN.

Examples

iex> Bankster.Iban.country_code("DK8387188644726815")
"DK"
@spec format_compact(binary()) :: binary()

Formats and returns a given IBAN in compact format.

Examples

iex> Bankster.Iban.format_compact("DK8     38 7188 64472     6815   ")
"DK8387188644726815"
@spec format_pretty(binary()) :: binary()

Formats and returns a given IBAN in pretty format.

Examples

iex> Bankster.Iban.format_pretty("DK8387188644726815")
"DK838 7188 64472 6815"
@spec size(binary()) :: integer()

Returns the size/length of the given IBAN.

Examples

iex> Bankster.Iban.size("DK 8387   188644     726815")
18
@spec supported_countries() :: [binary()]

Returns the country codes of the supported countries.

Examples

iex> Bankster.Iban.supported_countries()
["SM", "KZ", "SN", "BA", "GA", "KW", "MU", ...]
Link to this function

supported_country?(country_code)

View Source
@spec supported_country?(binary()) :: boolean()

Validates whether the given country code is within the supported countries.

Examples

iex> Bankster.Iban.supported_country?("DE")
true

iex> Bankster.Iban.supported_country?("XYZ")
false
@spec valid?(binary()) :: boolean()

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
@spec validate(binary()) :: {:ok, binary()} | {:error, atom()}

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"}