- Added `iban` field to the `IbanEx.Iban` struct to hold the full IBAN value. - Updated the parsing logic to populate the new field. - Adjusted BBAN rules and tests for France and Brazil to reflect updated structures. - Improved error handling and format validation routines.
50 lines
1.3 KiB
Elixir
50 lines
1.3 KiB
Elixir
defmodule IbanEx.Country.SC do
|
|
@moduledoc """
|
|
Seychelles IBAN parsing rules
|
|
|
|
## Examples
|
|
|
|
```elixir
|
|
iex> %IbanEx.Iban{
|
|
...> country_code: "SC",
|
|
...> check_digits: "18",
|
|
...> bank_code: "SSCB11",
|
|
...> branch_code: "01",
|
|
...> account_number: "0000000000001497USD"
|
|
...> }
|
|
...> |> IbanEx.Country.SC.to_string()
|
|
"SC 18 SSCB11 01 0000000000001497USD"
|
|
```
|
|
"""
|
|
|
|
@size 31
|
|
@rule ~r/^(?<bank_code>[A-Z]{4}[0-9]{2})(?<branch_code>[0-9]{2})(?<account_number>[0-9]{16}[A-Z]{3})$/i
|
|
|
|
use IbanEx.Country.Template
|
|
|
|
def rules() do
|
|
[
|
|
bank_code: %{regex: ~r/[A-Z0-9]{6}/i, range: 0..5},
|
|
branch_code: %{regex: ~r/[0-9]{2}/i, range: 6..7},
|
|
account_number: %{regex: ~r/[0-9A-Z]{19}/i, range: 8..26}
|
|
]
|
|
end
|
|
|
|
@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
|
|
} = _iban,
|
|
joiner \\ " "
|
|
) do
|
|
[country_code, check_digits, bank_code, branch_code, account_number]
|
|
|> Enum.join(joiner)
|
|
end
|
|
end
|