ADD IBAN FIELD TO STRUCTS AND UPDATE PARSING LOGIC

- 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.
This commit is contained in:
2025-11-30 11:04:09 -05:00
parent d197a86454
commit 763e1dba0c
21 changed files with 156 additions and 76 deletions

View File

@@ -25,7 +25,10 @@ def parse(iban_string, options \\ [incomplete: false])
def parse(iban_string, incomplete: false) do
case Validator.validate(iban_string) do
{:ok, valid_iban} ->
normalized = normalize_and_slice(valid_iban, 0..-1//1)
iban_map = %{
iban: normalized,
country_code: country_code(valid_iban),
check_digits: check_digits(valid_iban)
}
@@ -43,7 +46,10 @@ def parse(iban_string, incomplete: false) do
end
def parse(iban_string, incomplete: true) do
normalized = normalize_and_slice(iban_string, 0..-1//1)
iban_map = %{
iban: normalized,
country_code: country_code(iban_string),
check_digits: check_digits(iban_string)
}
@@ -72,6 +78,7 @@ def parse_bban(bban_string, country_code, incomplete: true) do
country_code
|> Country.country_module()
|> parse_bban_by_country_rules(bban_string)
false ->
%{}
end
@@ -82,6 +89,7 @@ def parse_bban(bban_string, country_code, incomplete: false) do
true ->
Country.country_module(country_code).rule()
|> parse_bban_by_regex(bban_string)
false ->
%{}
end