Added first non SEPA countries
This commit is contained in:
42
lib/iban_ex/country/ad.ex
Normal file
42
lib/iban_ex/country/ad.ex
Normal file
@@ -0,0 +1,42 @@
|
||||
defmodule IbanEx.Country.AD do
|
||||
@moduledoc """
|
||||
Andorra IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "AD",
|
||||
...> check_digits: "12",
|
||||
...> bank_code: "0001",
|
||||
...> branch_code: "2030",
|
||||
...> national_check: nil,
|
||||
...> account_number: "200359100100"
|
||||
...> }
|
||||
...> |> IbanEx.Country.AD.to_string()
|
||||
"AD 12 0001 2030 200359100100"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 24
|
||||
@rule ~r/^(?<bank_code>[0-9]{4})(?<branch_code>[0-9]{4})(?<account_number>[0-9A-Z]{12})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: branch_code,
|
||||
national_check: _national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, branch_code, account_number]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
25
lib/iban_ex/country/ae.ex
Normal file
25
lib/iban_ex/country/ae.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.AE do
|
||||
@moduledoc """
|
||||
United Arab Emirates IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "AE",
|
||||
...> check_digits: "07",
|
||||
...> bank_code: "033",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "1234567890123456"
|
||||
...> }
|
||||
...> |> IbanEx.Country.AE.to_string()
|
||||
"AE 07 033 1234567890123456"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 23
|
||||
@rule ~r/^(?<bank_code>[0-9]{3})(?<account_number>[0-9]{16})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
42
lib/iban_ex/country/al.ex
Normal file
42
lib/iban_ex/country/al.ex
Normal file
@@ -0,0 +1,42 @@
|
||||
defmodule IbanEx.Country.AL do
|
||||
@moduledoc """
|
||||
Albania IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "AL",
|
||||
...> check_digits: "47",
|
||||
...> bank_code: "212",
|
||||
...> branch_code: "1100",
|
||||
...> national_check: "9",
|
||||
...> account_number: "0000000235698741"
|
||||
...> }
|
||||
...> |> IbanEx.Country.AL.to_string()
|
||||
"AL 47 212 1100 9 0000000235698741"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 28
|
||||
@rule ~r/^(?<bank_code>[0-9]{3})(?<branch_code>[0-9]{4})(?<national_check>[0-9]{1})(?<account_number>[0-9A-Z]{16})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: branch_code,
|
||||
national_check: national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, branch_code, national_check, account_number]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
25
lib/iban_ex/country/az.ex
Normal file
25
lib/iban_ex/country/az.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.AZ do
|
||||
@moduledoc """
|
||||
Azerbaijan IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "AZ",
|
||||
...> check_digits: "21",
|
||||
...> bank_code: "NABZ",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "00000000137010001944"
|
||||
...> }
|
||||
...> |> IbanEx.Country.AZ.to_string()
|
||||
"AZ 21 NABZ 00000000137010001944"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 28
|
||||
@rule ~r/^(?<bank_code>[A-Z]{4})(?<account_number>[0-9A-Z]{20})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
42
lib/iban_ex/country/ba.ex
Normal file
42
lib/iban_ex/country/ba.ex
Normal file
@@ -0,0 +1,42 @@
|
||||
defmodule IbanEx.Country.BA do
|
||||
@moduledoc """
|
||||
Bosnia and Herzegovina IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "BA",
|
||||
...> check_digits: "39",
|
||||
...> bank_code: "129",
|
||||
...> branch_code: "007",
|
||||
...> national_check: "94",
|
||||
...> account_number: "94010284"
|
||||
...> }
|
||||
...> |> IbanEx.Country.BA.to_string()
|
||||
"BA 39 129 007 94010284 94"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 20
|
||||
@rule ~r/^(?<bank_code>[0-9]{3})(?<branch_code>[0-9]{3})(?<account_number>[0-9]{8})(?<national_check>[0-9]{2})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: branch_code,
|
||||
national_check: national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, branch_code, account_number, national_check]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
25
lib/iban_ex/country/bh.ex
Normal file
25
lib/iban_ex/country/bh.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.BH do
|
||||
@moduledoc """
|
||||
Bahrain IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "BH",
|
||||
...> check_digits: "67",
|
||||
...> bank_code: "BMAG",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "00001299123456"
|
||||
...> }
|
||||
...> |> IbanEx.Country.BH.to_string()
|
||||
"BH 67 BMAG 00001299123456"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 22
|
||||
@rule ~r/^(?<bank_code>[A-Z]{4})(?<account_number>[0-9]{14})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
42
lib/iban_ex/country/br.ex
Normal file
42
lib/iban_ex/country/br.ex
Normal file
@@ -0,0 +1,42 @@
|
||||
defmodule IbanEx.Country.BR do
|
||||
@moduledoc """
|
||||
Brazil IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "BR",
|
||||
...> check_digits: "18",
|
||||
...> bank_code: "00360305",
|
||||
...> branch_code: "00001",
|
||||
...> account_number: "0009795493",
|
||||
...> national_check: "C1"
|
||||
...> }
|
||||
...> |> IbanEx.Country.BR.to_string()
|
||||
"BR 18 00360305 00001 0009795493 C1"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 29
|
||||
@rule ~r/^(?<bank_code>[0-9]{8})(?<branch_code>[0-9]{5})(?<account_number>[0-9]{10})(?<national_check>[A-Z]{1}[0-9A-Z]{1})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: branch_code,
|
||||
account_number: account_number,
|
||||
national_check: national_check
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, branch_code, account_number, national_check]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.CH do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "CH", check_digits: "93", bank_code: "00762", branch_code: nil, national_check: nil, account_number: "011623852957"}
|
||||
iex> |> IbanEx.Country.CH.to_string()
|
||||
"CH 93 00762 011623852957"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "CH",
|
||||
...> check_digits: "93",
|
||||
...> bank_code: "00762",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "011623852957"
|
||||
...> }
|
||||
...> |> IbanEx.Country.CH.to_string()
|
||||
"CH 93 00762 011623852957"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 21
|
||||
|
||||
25
lib/iban_ex/country/cr.ex
Normal file
25
lib/iban_ex/country/cr.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.CR do
|
||||
@moduledoc """
|
||||
Costa Rica IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "CR",
|
||||
...> check_digits: "05",
|
||||
...> bank_code: "0152",
|
||||
...> branch_code: nil,
|
||||
...> account_number: "02001026284066",
|
||||
...> national_check: nil
|
||||
...> }
|
||||
...> |> IbanEx.Country.CR.to_string()
|
||||
"CR 05 0152 02001026284066"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 22
|
||||
@rule ~r/^(?<bank_code>[0-9]{4})(?<account_number>[0-9]{14})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.CY do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "CY", check_digits: "17", bank_code: "002", branch_code: "00128", national_check: nil, account_number: "0000001200527600"}
|
||||
iex> |> IbanEx.Country.CY.to_string()
|
||||
"CY 17 002 00128 0000001200527600"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "CY",
|
||||
...> check_digits: "17",
|
||||
...> bank_code: "002",
|
||||
...> branch_code: "00128",
|
||||
...> national_check: nil,
|
||||
...> account_number: "0000001200527600"
|
||||
...> }
|
||||
...> |> IbanEx.Country.CY.to_string()
|
||||
"CY 17 002 00128 0000001200527600"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 28
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.CZ do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "CZ", check_digits: "65", bank_code: "0800", branch_code: nil, national_check: nil, account_number: "0000192000145399"}
|
||||
iex> |> IbanEx.Country.CZ.to_string()
|
||||
"CZ 65 0800 0000192000145399"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "CZ",
|
||||
...> check_digits: "65",
|
||||
...> bank_code: "0800",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0000192000145399"
|
||||
...> }
|
||||
...> |> IbanEx.Country.CZ.to_string()
|
||||
"CZ 65 0800 0000192000145399"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 24
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.DE do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "DE", check_digits: "89", bank_code: "37040044", branch_code: nil, national_check: nil, account_number: "0532013000"}
|
||||
iex> |> IbanEx.Country.DE.to_string()
|
||||
"DE 89 37040044 0532013000"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "DE",
|
||||
...> check_digits: "89",
|
||||
...> bank_code: "37040044",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0532013000"
|
||||
...> }
|
||||
...> |> IbanEx.Country.DE.to_string()
|
||||
"DE 89 37040044 0532013000"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 22
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.DK do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "DK", check_digits: "50", bank_code: "0040", branch_code: nil, national_check: nil, account_number: "0440116243"}
|
||||
iex> |> IbanEx.Country.DK.to_string()
|
||||
"DK 50 0040 0440116243"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "DK",
|
||||
...> check_digits: "50",
|
||||
...> bank_code: "0040",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0440116243"
|
||||
...> }
|
||||
...> |> IbanEx.Country.DK.to_string()
|
||||
"DK 50 0040 0440116243"
|
||||
```
|
||||
"""
|
||||
@size 18
|
||||
@rule ~r/^(?<bank_code>[0-9]{4})(?<account_number>[0-9]{10})$/i
|
||||
|
||||
25
lib/iban_ex/country/do.ex
Normal file
25
lib/iban_ex/country/do.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.DO do
|
||||
@moduledoc """
|
||||
Dominican Republic IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "DO",
|
||||
...> check_digits: "28",
|
||||
...> bank_code: "BAGR",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "00000001212453611324"
|
||||
...> }
|
||||
...> |> IbanEx.Country.DO.to_string()
|
||||
"DO 28 BAGR 00000001212453611324"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 28
|
||||
@rule ~r/^(?<bank_code>[0-9A-Z]{4})(?<account_number>[0-9]{20})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.EE do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "EE", check_digits: "38", bank_code: "22", branch_code: "00", national_check: "5", account_number: "22102014568"}
|
||||
iex> |> IbanEx.Country.EE.to_string()
|
||||
"EE 38 22 00 22102014568 5"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "EE",
|
||||
...> check_digits: "38",
|
||||
...> bank_code: "22",
|
||||
...> branch_code: "00",
|
||||
...> national_check: "5",
|
||||
...> account_number: "22102014568"
|
||||
...> }
|
||||
...> |> IbanEx.Country.EE.to_string()
|
||||
"EE 38 22 00 22102014568 5"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 20
|
||||
|
||||
42
lib/iban_ex/country/eg.ex
Normal file
42
lib/iban_ex/country/eg.ex
Normal file
@@ -0,0 +1,42 @@
|
||||
defmodule IbanEx.Country.EG do
|
||||
@moduledoc """
|
||||
Egypt IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "EG",
|
||||
...> check_digits: "38",
|
||||
...> bank_code: "0019",
|
||||
...> branch_code: "0005",
|
||||
...> national_check: nil,
|
||||
...> account_number: "00000000263180002"
|
||||
...> }
|
||||
...> |> IbanEx.Country.EG.to_string()
|
||||
"EG 38 0019 0005 00000000263180002"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 29
|
||||
@rule ~r/^(?<bank_code>[0-9]{4})(?<branch_code>[0-9]{4})(?<account_number>[0-9]{17})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: branch_code,
|
||||
national_check: _national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, branch_code, account_number]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.ES do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "ES", check_digits: "91", bank_code: "2100", branch_code: "0418", national_check: "45", account_number: "0200051332"}
|
||||
iex> |> IbanEx.Country.ES.to_string()
|
||||
"ES 91 2100 0418 45 0200051332"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "ES",
|
||||
...> check_digits: "91",
|
||||
...> bank_code: "2100",
|
||||
...> branch_code: "0418",
|
||||
...> national_check: "45",
|
||||
...> account_number: "0200051332"
|
||||
...> }
|
||||
...> |> IbanEx.Country.ES.to_string()
|
||||
"ES 91 2100 0418 45 0200051332"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 24
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.FI do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "FI", check_digits: "21", bank_code: "123456", branch_code: nil, national_check: "5", account_number: "0000078"}
|
||||
iex> |> IbanEx.Country.FI.to_string()
|
||||
"FI 21 123456 0000078 5"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "FI",
|
||||
...> check_digits: "21",
|
||||
...> bank_code: "123456",
|
||||
...> branch_code: nil,
|
||||
...> national_check: "5",
|
||||
...> account_number: "0000078"
|
||||
...> }
|
||||
...> |> IbanEx.Country.FI.to_string()
|
||||
"FI 21 123456 0000078 5"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 18
|
||||
|
||||
43
lib/iban_ex/country/fo.ex
Normal file
43
lib/iban_ex/country/fo.ex
Normal file
@@ -0,0 +1,43 @@
|
||||
defmodule IbanEx.Country.FO do
|
||||
@moduledoc """
|
||||
Faroe Islands IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "FO",
|
||||
...> check_digits: "62",
|
||||
...> bank_code: "6460",
|
||||
...> branch_code: nil,
|
||||
...> national_check: "4",
|
||||
...> account_number: "000163163"
|
||||
...> }
|
||||
...> |> IbanEx.Country.FO.to_string()
|
||||
"FO 62 6460 000163163 4"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 18
|
||||
@rule ~r/^(?<bank_code>[0-9]{4})(?<account_number>[0-9]{9})(?<national_check>[0-9]{1})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: _branch_code,
|
||||
national_check: national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, account_number, national_check]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.FR do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "FR", check_digits: "14", bank_code: "20041", branch_code: "01005", national_check: "06", account_number: "0500013M026"}
|
||||
iex> |> IbanEx.Country.FR.to_string()
|
||||
"FR 14 20041 01005 0500013M026 06"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "FR",
|
||||
...> check_digits: "14",
|
||||
...> bank_code: "20041",
|
||||
...> branch_code: "01005",
|
||||
...> national_check: "06",
|
||||
...> account_number: "0500013M026"
|
||||
...> }
|
||||
...> |> IbanEx.Country.FR.to_string()
|
||||
"FR 14 20041 01005 0500013M026 06"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 27
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.GB do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "GB", check_digits: "29", bank_code: "NWBK", branch_code: "601613", national_check: "06", account_number: "31926819"}
|
||||
iex> |> IbanEx.Country.GB.to_string()
|
||||
"GB 29 NWBK 601613 31926819"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "GB",
|
||||
...> check_digits: "29",
|
||||
...> bank_code: "NWBK",
|
||||
...> branch_code: "601613",
|
||||
...> national_check: "06",
|
||||
...> account_number: "31926819"
|
||||
...> }
|
||||
...> |> IbanEx.Country.GB.to_string()
|
||||
"GB 29 NWBK 601613 31926819"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 22
|
||||
|
||||
25
lib/iban_ex/country/ge.ex
Normal file
25
lib/iban_ex/country/ge.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.GE do
|
||||
@moduledoc """
|
||||
Georgia IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "GE",
|
||||
...> check_digits: "29",
|
||||
...> bank_code: "NB",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0000000101904917"
|
||||
...> }
|
||||
...> |> IbanEx.Country.GE.to_string()
|
||||
"GE 29 NB 0000000101904917"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 22
|
||||
@rule ~r/^(?<bank_code>[A-Z]{2})(?<account_number>[0-9]{16})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.GI do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "GI", check_digits: "75", bank_code: "NWBK", branch_code: nil, national_check: nil, account_number: "000000007099453"}
|
||||
iex> |> IbanEx.Country.GI.to_string()
|
||||
"GI 75 NWBK 000000007099453"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "GI",
|
||||
...> check_digits: "75",
|
||||
...> bank_code: "NWBK",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "000000007099453"
|
||||
...> }
|
||||
...> |> IbanEx.Country.GI.to_string()
|
||||
"GI 75 NWBK 000000007099453"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 23
|
||||
|
||||
25
lib/iban_ex/country/gl.ex
Normal file
25
lib/iban_ex/country/gl.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.GL do
|
||||
@moduledoc """
|
||||
Greenland IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "GL",
|
||||
...> check_digits: "89",
|
||||
...> bank_code: "6471",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0001000206"
|
||||
...> }
|
||||
...> |> IbanEx.Country.GL.to_string()
|
||||
"GL 89 6471 0001000206"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 18
|
||||
@rule ~r/^(?<bank_code>[0-9]{4})(?<account_number>[0-9]{10})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.GR do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "GR", check_digits: "16", bank_code: "011", branch_code: "0125", national_check: nil, account_number: "0000000012300695"}
|
||||
iex> |> IbanEx.Country.GR.to_string()
|
||||
"GR 16 011 0125 0000000012300695"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "GR",
|
||||
...> check_digits: "16",
|
||||
...> bank_code: "011",
|
||||
...> branch_code: "0125",
|
||||
...> national_check: nil,
|
||||
...> account_number: "0000000012300695"
|
||||
...> }
|
||||
...> |> IbanEx.Country.GR.to_string()
|
||||
"GR 16 011 0125 0000000012300695"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 27
|
||||
|
||||
25
lib/iban_ex/country/gt.ex
Normal file
25
lib/iban_ex/country/gt.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.GT do
|
||||
@moduledoc """
|
||||
Guatemala IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "GT",
|
||||
...> check_digits: "82",
|
||||
...> bank_code: "TRAJ",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "01020000001210029690"
|
||||
...> }
|
||||
...> |> IbanEx.Country.GT.to_string()
|
||||
"GT 82 TRAJ 01020000001210029690"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 28
|
||||
@rule ~r/^(?<bank_code>[A-Z]{4})(?<account_number>[0-9]{20})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.HR do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "HR", check_digits: "12", bank_code: "1001005", branch_code: nil, national_check: nil, account_number: "1863000160"}
|
||||
iex> |> IbanEx.Country.HR.to_string()
|
||||
"HR 12 1001005 1863000160"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "HR",
|
||||
...> check_digits: "12",
|
||||
...> bank_code: "1001005",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "1863000160"
|
||||
...> }
|
||||
...> |> IbanEx.Country.HR.to_string()
|
||||
"HR 12 1001005 1863000160"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 21
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.HU do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "HU", check_digits: "42", bank_code: "117", branch_code: "7301", national_check: "0", account_number: "6111110180000000"}
|
||||
iex> |> IbanEx.Country.HU.to_string()
|
||||
"HU 42 117 7301 6111110180000000 0"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "HU",
|
||||
...> check_digits: "42",
|
||||
...> bank_code: "117",
|
||||
...> branch_code: "7301",
|
||||
...> national_check: "0",
|
||||
...> account_number: "6111110180000000"
|
||||
...> }
|
||||
...> |> IbanEx.Country.HU.to_string()
|
||||
"HU 42 117 7301 6111110180000000 0"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 28
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.IE do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "IE", check_digits: "29", bank_code: "AIBK", branch_code: "931152", national_check: nil, account_number: "12345678"}
|
||||
iex> |> IbanEx.Country.IE.to_string()
|
||||
"IE 29 AIBK 931152 12345678"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "IE",
|
||||
...> check_digits: "29",
|
||||
...> bank_code: "AIBK",
|
||||
...> branch_code: "931152",
|
||||
...> national_check: nil,
|
||||
...> account_number: "12345678"
|
||||
...> }
|
||||
...> |> IbanEx.Country.IE.to_string()
|
||||
"IE 29 AIBK 931152 12345678"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 22
|
||||
|
||||
42
lib/iban_ex/country/il.ex
Normal file
42
lib/iban_ex/country/il.ex
Normal file
@@ -0,0 +1,42 @@
|
||||
defmodule IbanEx.Country.IL do
|
||||
@moduledoc """
|
||||
Israel IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "IL",
|
||||
...> check_digits: "62",
|
||||
...> bank_code: "010",
|
||||
...> branch_code: "800",
|
||||
...> national_check: nil,
|
||||
...> account_number: "0000099999999"
|
||||
...> }
|
||||
...> |> IbanEx.Country.IL.to_string()
|
||||
"IL 62 010 800 0000099999999"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 23
|
||||
@rule ~r/^(?<bank_code>[0-9]{3})(?<branch_code>[0-9]{3})(?<account_number>[0-9]{13})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: branch_code,
|
||||
national_check: _national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, branch_code, account_number]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.IT do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "IT", check_digits: "60", bank_code: "05428", branch_code: "11101", national_check: "X", account_number: "000000123456"}
|
||||
iex> |> IbanEx.Country.IT.to_string()
|
||||
"IT 60 X 05428 11101 000000123456"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "IT",
|
||||
...> check_digits: "60",
|
||||
...> bank_code: "05428",
|
||||
...> branch_code: "11101",
|
||||
...> national_check: "X",
|
||||
...> account_number: "000000123456"
|
||||
...> }
|
||||
...> |> IbanEx.Country.IT.to_string()
|
||||
"IT 60 X 05428 11101 000000123456"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 27
|
||||
|
||||
42
lib/iban_ex/country/jo.ex
Normal file
42
lib/iban_ex/country/jo.ex
Normal file
@@ -0,0 +1,42 @@
|
||||
defmodule IbanEx.Country.JO do
|
||||
@moduledoc """
|
||||
Jordan IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "JO",
|
||||
...> check_digits: "94",
|
||||
...> bank_code: "CBJO",
|
||||
...> branch_code: "0010",
|
||||
...> national_check: nil,
|
||||
...> account_number: "000000000131000302"
|
||||
...> }
|
||||
...> |> IbanEx.Country.JO.to_string()
|
||||
"JO 94 CBJO 0010 000000000131000302"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 30
|
||||
@rule ~r/^(?<bank_code>[A-Z0-9]{4})(?<branch_code>[0-9]{4})(?<account_number>[A-Z0-9]{18})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: branch_code,
|
||||
national_check: _national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, branch_code, account_number]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
25
lib/iban_ex/country/kw.ex
Normal file
25
lib/iban_ex/country/kw.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.KW do
|
||||
@moduledoc """
|
||||
Kuwait IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "KW",
|
||||
...> check_digits: "81",
|
||||
...> bank_code: "CBKU",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0000000000001234560101"
|
||||
...> }
|
||||
...> |> IbanEx.Country.KW.to_string()
|
||||
"KW 81 CBKU 0000000000001234560101"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 30
|
||||
@rule ~r/^(?<bank_code>[A-Z0-9]{4})(?<account_number>[0-9]{22})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
25
lib/iban_ex/country/kz.ex
Normal file
25
lib/iban_ex/country/kz.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.KZ do
|
||||
@moduledoc """
|
||||
Kazakhstan IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "KZ",
|
||||
...> check_digits: "86",
|
||||
...> bank_code: "125",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "KZT5004100100"
|
||||
...> }
|
||||
...> |> IbanEx.Country.KZ.to_string()
|
||||
"KZ 86 125 KZT5004100100"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 20
|
||||
@rule ~r/^(?<bank_code>[0-9]{3})(?<account_number>[A-Z0-9]{13})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
25
lib/iban_ex/country/lb.ex
Normal file
25
lib/iban_ex/country/lb.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.LB do
|
||||
@moduledoc """
|
||||
Lebanon IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "LB",
|
||||
...> check_digits: "62",
|
||||
...> bank_code: "0999",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "00000001001901229114"
|
||||
...> }
|
||||
...> |> IbanEx.Country.LB.to_string()
|
||||
"LB 62 0999 00000001001901229114"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 28
|
||||
@rule ~r/^(?<bank_code>[0-9]{4})(?<account_number>[0-9]{20})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.LI do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "LI", check_digits: "21", bank_code: "08810", branch_code: nil, national_check: nil, account_number: "0002324013AA"}
|
||||
iex> |> IbanEx.Country.LI.to_string()
|
||||
"LI 21 08810 0002324013AA"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "LI",
|
||||
...> check_digits: "21",
|
||||
...> bank_code: "08810",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0002324013AA"
|
||||
...> }
|
||||
...> |> IbanEx.Country.LI.to_string()
|
||||
"LI 21 08810 0002324013AA"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 21
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.LT do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "LT", check_digits: "12", bank_code: "10000", branch_code: nil, national_check: nil, account_number: "11101001000"}
|
||||
iex> |> IbanEx.Country.LT.to_string()
|
||||
"LT 12 10000 11101001000"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "LT",
|
||||
...> check_digits: "12",
|
||||
...> bank_code: "10000",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "11101001000"
|
||||
...> }
|
||||
...> |> IbanEx.Country.LT.to_string()
|
||||
"LT 12 10000 11101001000"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 20
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.LU do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "LU", check_digits: "28", bank_code: "001", branch_code: nil, national_check: nil, account_number: "9400644750000"}
|
||||
iex> |> IbanEx.Country.LU.to_string()
|
||||
"LU 28 001 9400644750000"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "LU",
|
||||
...> check_digits: "28",
|
||||
...> bank_code: "001",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "9400644750000"
|
||||
...> }
|
||||
...> |> IbanEx.Country.LU.to_string()
|
||||
"LU 28 001 9400644750000"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 20
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.LV do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "LV", check_digits: "80", bank_code: "BANK", branch_code: nil, national_check: nil, account_number: "0000435195001"}
|
||||
iex> |> IbanEx.Country.LV.to_string()
|
||||
"LV 80 BANK 0000435195001"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "LV",
|
||||
...> check_digits: "80",
|
||||
...> bank_code: "BANK",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0000435195001"
|
||||
...> }
|
||||
...> |> IbanEx.Country.LV.to_string()
|
||||
"LV 80 BANK 0000435195001"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 21
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.MC do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "MC", check_digits: "58", bank_code: "11222", branch_code: "00001", national_check: "30", account_number: "01234567890"}
|
||||
iex> |> IbanEx.Country.MC.to_string()
|
||||
"MC 58 11222 00001 01234567890 30"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "MC",
|
||||
...> check_digits: "58",
|
||||
...> bank_code: "11222",
|
||||
...> branch_code: "00001",
|
||||
...> national_check: "30",
|
||||
...> account_number: "01234567890"
|
||||
...> }
|
||||
...> |> IbanEx.Country.MC.to_string()
|
||||
"MC 58 11222 00001 01234567890 30"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 27
|
||||
|
||||
25
lib/iban_ex/country/md.ex
Normal file
25
lib/iban_ex/country/md.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.MD do
|
||||
@moduledoc """
|
||||
Republic of Moldova IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "MD",
|
||||
...> check_digits: "24",
|
||||
...> bank_code: "AG",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "000225100013104168"
|
||||
...> }
|
||||
...> |> IbanEx.Country.MD.to_string()
|
||||
"MD 24 AG 000225100013104168"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 24
|
||||
@rule ~r/^(?<bank_code>[A-Z]{2})(?<account_number>[0-9]{18})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
43
lib/iban_ex/country/me.ex
Normal file
43
lib/iban_ex/country/me.ex
Normal file
@@ -0,0 +1,43 @@
|
||||
defmodule IbanEx.Country.ME do
|
||||
@moduledoc """
|
||||
Montenegro IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "ME",
|
||||
...> check_digits: "25",
|
||||
...> bank_code: "505",
|
||||
...> branch_code: nil,
|
||||
...> national_check: "51",
|
||||
...> account_number: "0000123456789"
|
||||
...> }
|
||||
...> |> IbanEx.Country.ME.to_string()
|
||||
"ME 25 505 0000123456789 51"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 22
|
||||
@rule ~r/^(?<bank_code>[0-9]{3})(?<account_number>[0-9]{13})(?<national_check>[0-9]{2})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: _branch_code,
|
||||
national_check: national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, account_number, national_check]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
43
lib/iban_ex/country/mk.ex
Normal file
43
lib/iban_ex/country/mk.ex
Normal file
@@ -0,0 +1,43 @@
|
||||
defmodule IbanEx.Country.MK do
|
||||
@moduledoc """
|
||||
Macedonia IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "MK",
|
||||
...> check_digits: "07",
|
||||
...> bank_code: "250",
|
||||
...> branch_code: nil,
|
||||
...> national_check: "84",
|
||||
...> account_number: "1200000589"
|
||||
...> }
|
||||
...> |> IbanEx.Country.MK.to_string()
|
||||
"MK 07 250 1200000589 84"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 19
|
||||
@rule ~r/^(?<bank_code>[0-9]{3})(?<account_number>[0-9]{10})(?<national_check>[0-9]{2})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: _branch_code,
|
||||
national_check: national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, account_number, national_check]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
43
lib/iban_ex/country/mr.ex
Normal file
43
lib/iban_ex/country/mr.ex
Normal file
@@ -0,0 +1,43 @@
|
||||
defmodule IbanEx.Country.MR do
|
||||
@moduledoc """
|
||||
Mauritania IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "MR",
|
||||
...> check_digits: "13",
|
||||
...> bank_code: "00020",
|
||||
...> branch_code: "00101",
|
||||
...> national_check: "53",
|
||||
...> account_number: "00001234567"
|
||||
...> }
|
||||
...> |> IbanEx.Country.MR.to_string()
|
||||
"MR 13 00020 00101 00001234567 53"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 27
|
||||
@rule ~r/^(?<bank_code>[0-9]{5})(?<branch_code>[0-9]{5})(?<account_number>[0-9]{11})(?<national_check>[0-9]{2})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: branch_code,
|
||||
national_check: national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, branch_code, account_number, national_check]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.MT do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "MT", check_digits: "84", bank_code: "MALT", branch_code: "01100", national_check: nil, account_number: "0012345MTLCAST001S"}
|
||||
iex> |> IbanEx.Country.MT.to_string()
|
||||
"MT 84 MALT 01100 0012345MTLCAST001S"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "MT",
|
||||
...> check_digits: "84",
|
||||
...> bank_code: "MALT",
|
||||
...> branch_code: "01100",
|
||||
...> national_check: nil,
|
||||
...> account_number: "0012345MTLCAST001S"
|
||||
...> }
|
||||
...> |> IbanEx.Country.MT.to_string()
|
||||
"MT 84 MALT 01100 0012345MTLCAST001S"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 31
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.NL do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "NL", check_digits: "91", bank_code: "ABNA", branch_code: nil, national_check: nil, account_number: "0417164300"}
|
||||
iex> |> IbanEx.Country.NL.to_string()
|
||||
"NL 91 ABNA 0417164300"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "NL",
|
||||
...> check_digits: "91",
|
||||
...> bank_code: "ABNA",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0417164300"
|
||||
...> }
|
||||
...> |> IbanEx.Country.NL.to_string()
|
||||
"NL 91 ABNA 0417164300"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 18
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.NO do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "NO", check_digits: "93", bank_code: "8601", branch_code: nil, national_check: "7", account_number: "111794"}
|
||||
iex> |> IbanEx.Country.NO.to_string()
|
||||
"NO 93 8601 111794 7"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "NO",
|
||||
...> check_digits: "93",
|
||||
...> bank_code: "8601",
|
||||
...> branch_code: nil,
|
||||
...> national_check: "7",
|
||||
...> account_number: "111794"
|
||||
...> }
|
||||
...> |> IbanEx.Country.NO.to_string()
|
||||
"NO 93 8601 111794 7"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 15
|
||||
|
||||
25
lib/iban_ex/country/pk.ex
Normal file
25
lib/iban_ex/country/pk.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.PK do
|
||||
@moduledoc """
|
||||
Pakistan IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "PK",
|
||||
...> check_digits: "36",
|
||||
...> bank_code: "SCBL",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0000001123456702"
|
||||
...> }
|
||||
...> |> IbanEx.Country.PK.to_string()
|
||||
"PK 36 SCBL 0000001123456702"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 24
|
||||
@rule ~r/^(?<bank_code>[A-Z]{4})(?<account_number>[0-9]{16})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.PL do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "PL", check_digits: "61", bank_code: "109", branch_code: "0101", national_check: "4", account_number: "0000071219812874"}
|
||||
iex> |> IbanEx.Country.PL.to_string()
|
||||
"PL 61 109 0101 4 0000071219812874"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "PL",
|
||||
...> check_digits: "61",
|
||||
...> bank_code: "109",
|
||||
...> branch_code: "0101",
|
||||
...> national_check: "4",
|
||||
...> account_number: "0000071219812874"
|
||||
...> }
|
||||
...> |> IbanEx.Country.PL.to_string()
|
||||
"PL 61 109 0101 4 0000071219812874"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 28
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.PT do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "PT", check_digits: "50", bank_code: "0002", branch_code: "0123", national_check: "54", account_number: "12345678901"}
|
||||
iex> |> IbanEx.Country.PT.to_string()
|
||||
"PT 50 0002 0123 12345678901 54"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "PT",
|
||||
...> check_digits: "50",
|
||||
...> bank_code: "0002",
|
||||
...> branch_code: "0123",
|
||||
...> national_check: "54",
|
||||
...> account_number: "12345678901"
|
||||
...> }
|
||||
...> |> IbanEx.Country.PT.to_string()
|
||||
"PT 50 0002 0123 12345678901 54"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 25
|
||||
|
||||
25
lib/iban_ex/country/qa.ex
Normal file
25
lib/iban_ex/country/qa.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.QA do
|
||||
@moduledoc """
|
||||
Qatar IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "QA",
|
||||
...> check_digits: "58",
|
||||
...> bank_code: "DOHB",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "00001234567890ABCDEFG"
|
||||
...> }
|
||||
...> |> IbanEx.Country.QA.to_string()
|
||||
"QA 58 DOHB 00001234567890ABCDEFG"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 29
|
||||
@rule ~r/^(?<bank_code>[A-Z]{4})(?<account_number>[A-Z0-9]{21})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.RO do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "RO", check_digits: "49", bank_code: "AAAA", branch_code: nil, national_check: nil, account_number: "1B31007593840000"}
|
||||
iex> |> IbanEx.Country.RO.to_string()
|
||||
"RO 49 AAAA 1B31007593840000"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "RO",
|
||||
...> check_digits: "49",
|
||||
...> bank_code: "AAAA",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "1B31007593840000"
|
||||
...> }
|
||||
...> |> IbanEx.Country.RO.to_string()
|
||||
"RO 49 AAAA 1B31007593840000"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 24
|
||||
|
||||
43
lib/iban_ex/country/rs.ex
Normal file
43
lib/iban_ex/country/rs.ex
Normal file
@@ -0,0 +1,43 @@
|
||||
defmodule IbanEx.Country.RS do
|
||||
@moduledoc """
|
||||
Serbia IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "RS",
|
||||
...> check_digits: "35",
|
||||
...> bank_code: "260",
|
||||
...> branch_code: nil,
|
||||
...> national_check: "79",
|
||||
...> account_number: "0056010016113"
|
||||
...> }
|
||||
...> |> IbanEx.Country.RS.to_string()
|
||||
"RS 35 260 0056010016113 79"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 22
|
||||
@rule ~r/^(?<bank_code>[0-9]{3})(?<account_number>[0-9]{13})(?<national_check>[0-9]{2})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: _branch_code,
|
||||
national_check: national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, account_number, national_check]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
25
lib/iban_ex/country/sa.ex
Normal file
25
lib/iban_ex/country/sa.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.SA do
|
||||
@moduledoc """
|
||||
Saudi Arabia IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "SA",
|
||||
...> check_digits: "03",
|
||||
...> bank_code: "80",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "000000608010167519"
|
||||
...> }
|
||||
...> |> IbanEx.Country.SA.to_string()
|
||||
"SA 03 80 000000608010167519"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 24
|
||||
@rule ~r/^(?<bank_code>[0-9]{2})(?<account_number>[0-9]{18})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.SE do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "SE", check_digits: "45", bank_code: "500", branch_code: nil, national_check: nil, account_number: "00000058398257466"}
|
||||
iex> |> IbanEx.Country.SE.to_string()
|
||||
"SE 45 500 00000058398257466"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "SE",
|
||||
...> check_digits: "45",
|
||||
...> bank_code: "500",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "00000058398257466"
|
||||
...> }
|
||||
...> |> IbanEx.Country.SE.to_string()
|
||||
"SE 45 500 00000058398257466"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 24
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.SI do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "SI", check_digits: "56", bank_code: "26", branch_code: "330", national_check: "86", account_number: "00120390"}
|
||||
iex> |> IbanEx.Country.SI.to_string()
|
||||
"SI 56 26 330 00120390 86"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "SI",
|
||||
...> check_digits: "56",
|
||||
...> bank_code: "26",
|
||||
...> branch_code: "330",
|
||||
...> national_check: "86",
|
||||
...> account_number: "00120390"
|
||||
...> }
|
||||
...> |> IbanEx.Country.SI.to_string()
|
||||
"SI 56 26 330 00120390 86"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 19
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.SK do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "SK", check_digits: "31", bank_code: "1200", branch_code: nil, national_check: nil, account_number: "0000198742637541"}
|
||||
iex> |> IbanEx.Country.SK.to_string()
|
||||
"SK 31 1200 0000198742637541"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "SK",
|
||||
...> check_digits: "31",
|
||||
...> bank_code: "1200",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0000198742637541"
|
||||
...> }
|
||||
...> |> IbanEx.Country.SK.to_string()
|
||||
"SK 31 1200 0000198742637541"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 24
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.SM do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "SM", check_digits: "86", bank_code: "03225", branch_code: "09800", national_check: "U", account_number: "000000270100"}
|
||||
iex> |> IbanEx.Country.SM.to_string()
|
||||
"SM 86 U 03225 09800 000000270100"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "SM",
|
||||
...> check_digits: "86",
|
||||
...> bank_code: "03225",
|
||||
...> branch_code: "09800",
|
||||
...> national_check: "U",
|
||||
...> account_number: "000000270100"
|
||||
...> }
|
||||
...> |> IbanEx.Country.SM.to_string()
|
||||
"SM 86 U 03225 09800 000000270100"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 27
|
||||
|
||||
25
lib/iban_ex/country/sv.ex
Normal file
25
lib/iban_ex/country/sv.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.SV do
|
||||
@moduledoc """
|
||||
El Salvador IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "SV",
|
||||
...> check_digits: "62",
|
||||
...> bank_code: "CENR",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "00000000000000700025"
|
||||
...> }
|
||||
...> |> IbanEx.Country.SV.to_string()
|
||||
"SV 62 CENR 00000000000000700025"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 28
|
||||
@rule ~r/^(?<bank_code>[A-Z0-9]{4})(?<account_number>[0-9]{20})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
@@ -36,7 +36,7 @@ def to_string(
|
||||
end
|
||||
|
||||
@impl IbanEx.Country.Template
|
||||
@spec size() :: Integer.t()
|
||||
@spec size() :: integer()
|
||||
def size(), do: @size
|
||||
|
||||
@impl IbanEx.Country.Template
|
||||
|
||||
43
lib/iban_ex/country/tl.ex
Normal file
43
lib/iban_ex/country/tl.ex
Normal file
@@ -0,0 +1,43 @@
|
||||
defmodule IbanEx.Country.TL do
|
||||
@moduledoc """
|
||||
Timor-Leste IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "TL",
|
||||
...> check_digits: "38",
|
||||
...> bank_code: "008",
|
||||
...> branch_code: nil,
|
||||
...> national_check: "57",
|
||||
...> account_number: "00123456789101"
|
||||
...> }
|
||||
...> |> IbanEx.Country.TL.to_string()
|
||||
"TL 38 008 00123456789101 57"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 23
|
||||
@rule ~r/^(?<bank_code>[0-9]{3})(?<account_number>[0-9]{14})(?<national_check>[0-9]{2})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: _branch_code,
|
||||
national_check: national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, account_number, national_check]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
43
lib/iban_ex/country/tr.ex
Normal file
43
lib/iban_ex/country/tr.ex
Normal file
@@ -0,0 +1,43 @@
|
||||
defmodule IbanEx.Country.TR do
|
||||
@moduledoc """
|
||||
Turkey IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "TR",
|
||||
...> check_digits: "33",
|
||||
...> bank_code: "00061",
|
||||
...> branch_code: nil,
|
||||
...> national_check: "0",
|
||||
...> account_number: "0519786457841326"
|
||||
...> }
|
||||
...> |> IbanEx.Country.TR.to_string()
|
||||
"TR 33 00061 0 0519786457841326"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 26
|
||||
@rule ~r/^(?<bank_code>[A-Z0-9]{5})(?<national_check>[0-9]{1})(?<account_number>[0-9]{16})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: _branch_code,
|
||||
national_check: national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, national_check, account_number]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.UA do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "UA", check_digits: "21", bank_code: "322313", branch_code: nil, national_check: nil, account_number: "0000026007233566001"}
|
||||
iex> |> IbanEx.Country.UA.to_string()
|
||||
"UA 21 322313 0000026007233566001"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "UA",
|
||||
...> check_digits: "21",
|
||||
...> bank_code: "322313",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0000026007233566001"
|
||||
...> }
|
||||
...> |> IbanEx.Country.UA.to_string()
|
||||
"UA 21 322313 0000026007233566001"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 29
|
||||
|
||||
@@ -4,10 +4,18 @@ defmodule IbanEx.Country.VA do
|
||||
|
||||
## Examples
|
||||
|
||||
iex> %IbanEx.Iban{country_code: "VA", check_digits: "59", bank_code: "001", branch_code: nil, national_check: nil, account_number: "123000012345678"}
|
||||
iex> |> IbanEx.Country.VA.to_string()
|
||||
"VA 59 001 123000012345678"
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "VA",
|
||||
...> check_digits: "59",
|
||||
...> bank_code: "001",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "123000012345678"
|
||||
...> }
|
||||
...> |> IbanEx.Country.VA.to_string()
|
||||
"VA 59 001 123000012345678"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 22
|
||||
|
||||
25
lib/iban_ex/country/vg.ex
Normal file
25
lib/iban_ex/country/vg.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
defmodule IbanEx.Country.VG do
|
||||
@moduledoc """
|
||||
British Virgin Islands IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "VG",
|
||||
...> check_digits: "96",
|
||||
...> bank_code: "VPVG",
|
||||
...> branch_code: nil,
|
||||
...> national_check: nil,
|
||||
...> account_number: "0000012345678901"
|
||||
...> }
|
||||
...> |> IbanEx.Country.VG.to_string()
|
||||
"VG 96 VPVG 0000012345678901"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 24
|
||||
@rule ~r/^(?<bank_code>[A-Z]{4})(?<account_number>[0-9]{16})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
end
|
||||
43
lib/iban_ex/country/xk.ex
Normal file
43
lib/iban_ex/country/xk.ex
Normal file
@@ -0,0 +1,43 @@
|
||||
defmodule IbanEx.Country.XK do
|
||||
@moduledoc """
|
||||
Kosovo IBAN parsing rules
|
||||
|
||||
## Examples
|
||||
|
||||
```elixir
|
||||
iex> %IbanEx.Iban{
|
||||
...> country_code: "XK",
|
||||
...> check_digits: "05",
|
||||
...> bank_code: "12",
|
||||
...> branch_code: "12",
|
||||
...> national_check: "06",
|
||||
...> account_number: "0123456789"
|
||||
...> }
|
||||
...> |> IbanEx.Country.XK.to_string()
|
||||
"XK 05 12 12 0123456789 06"
|
||||
```
|
||||
"""
|
||||
|
||||
@size 20
|
||||
@rule ~r/^(?<bank_code>[0-9]{2})(?<branch_code>[0-9]{2})(?<account_number>[0-9]{10})(?<national_check>[0-9]{2})$/i
|
||||
|
||||
use IbanEx.Country.Template
|
||||
|
||||
@impl IbanEx.Country.Template
|
||||
@spec to_string(Iban.t()) :: binary()
|
||||
@spec to_string(Iban.t(), binary()) :: binary()
|
||||
def to_string(
|
||||
%Iban{
|
||||
country_code: country_code,
|
||||
check_digits: check_digits,
|
||||
bank_code: bank_code,
|
||||
branch_code: branch_code,
|
||||
national_check: national_check,
|
||||
account_number: account_number
|
||||
} = _iban,
|
||||
joiner \\ " "
|
||||
) do
|
||||
[country_code, check_digits, bank_code, branch_code, account_number, national_check]
|
||||
|> Enum.join(joiner)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user