Compare commits
No commits in common. "368225f3317935e1178b79d580e45d2ac357dd84" and "6b8715533b27ce66ed4345855022425f6a9dad44" have entirely different histories.
368225f331
...
6b8715533b
55
README.md
55
README.md
|
@ -1,59 +1,6 @@
|
|||
# IbanEx
|
||||
|
||||
Elixir library for working with IBAN numbers (parsing, validating, checking and formatting)
|
||||
|
||||
## What is an IBAN?
|
||||
|
||||
IBAN (which stands for International Bank Account Number) is an internationally agreed code made up of up to 34 letters and numbers which helps banks make sure that international transfers are processed correctly.
|
||||
|
||||
In just a few letters and numbers, the IBAN captures all of the country, bank, and account details you need to send or receive money internationally. This system is used throughout Europe, and also recognised in some areas of the Middle East, North Africa and the Caribbean. Find IBAN examples for every country where it's used.
|
||||
|
||||
## HowTo Use
|
||||
|
||||
### Successfull case to parse IBAN
|
||||
|
||||
Parse string with valid formatted IBAN from supported country
|
||||
|
||||
```elixir
|
||||
{:ok, iban} = "FI2112345600000785" |> IbanEx.Parser.parse()
|
||||
IO.inspect(iban)
|
||||
IbanEx.Iban.pretty(iban)
|
||||
```
|
||||
|
||||
#### Response
|
||||
|
||||
%IbanEx.Iban{
|
||||
country_code: "FI",
|
||||
check_digits: "21",
|
||||
bank_code: "123456",
|
||||
branch_code: nil,
|
||||
national_check: "5",
|
||||
account_number: "0000078"
|
||||
}
|
||||
|
||||
"FI 21 123456 0000078 5"
|
||||
|
||||
### Errors cases of IBAN parsing
|
||||
|
||||
Parse strings with invalid formatted IBANs from unsupported and supported countries
|
||||
|
||||
```elixir
|
||||
{:error, unsupported_country_code} = "AZ21NABZ00000000137010001944" |> IbanEx.Parser.parse()
|
||||
IO.inspect(IbanEx.Error.message(unsupported_country_code), label: unsupported_country_code)
|
||||
|
||||
{:error, invalid_length_code} = "AT6119043002345732012" |> IbanEx.Parser.parse()
|
||||
IO.inspect(IbanEx.Error.message(invalid_length_code), label: invalid_length_code)
|
||||
|
||||
{:error, invalid_checksum} = "AT621904300234573201" |> IbanEx.Parser.parse()
|
||||
IO.inspect(IbanEx.Error.message(invalid_checksum), label: invalid_checksum)
|
||||
```
|
||||
|
||||
#### Response
|
||||
|
||||
unsupported_country_code: "Unsupported country code"
|
||||
invalid_length: "IBAN violates the required length"
|
||||
invalid_checksum: "IBAN's checksum is invalid"
|
||||
|
||||
Library for working with IBAN numbers (parsing, validating and checking and formatting)
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ defimpl IbanEx.Deserialize, for: Map do
|
|||
country_code: _country_code,
|
||||
check_digits: _check_sum_digits,
|
||||
bank_code: _bank_code,
|
||||
branch_code: _branch_code,
|
||||
national_check: _national_check,
|
||||
account_number: _account_number
|
||||
} = map
|
||||
) do
|
||||
|
@ -40,8 +38,6 @@ defimpl IbanEx.Deserialize, for: Map do
|
|||
"country_code" => _country_code,
|
||||
"check_digits" => _check_sum_digits,
|
||||
"bank_code" => _bank_code,
|
||||
"branch_code" => _branch_code,
|
||||
"national_check" => _national_check,
|
||||
"account_number" => _account_number
|
||||
} = map
|
||||
) do
|
||||
|
@ -51,11 +47,3 @@ defimpl IbanEx.Deserialize, for: Map do
|
|||
|
||||
def to_iban(map) when is_map(map), do: {:error, :can_not_parse_map}
|
||||
end
|
||||
|
||||
defimpl IbanEx.Deserialize, for: List do
|
||||
alias IbanEx.Iban
|
||||
@type iban_or_error() :: IbanEx.Iban.t() | {:error, :can_not_parse_map}
|
||||
|
||||
@spec to_iban(list()) :: iban_or_error()
|
||||
def to_iban(list), do: struct(Iban, Map.new(list))
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue