Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5cfc3f5fa2 | |||
| ce90960649 |
@@ -45,13 +45,23 @@ def parse(iban_string) do
|
|||||||
def parse_bban(bban_string, country_code, options \\ [incomplete: false])
|
def parse_bban(bban_string, country_code, options \\ [incomplete: false])
|
||||||
|
|
||||||
def parse_bban(bban_string, country_code, incomplete: true) do
|
def parse_bban(bban_string, country_code, incomplete: true) do
|
||||||
|
case Country.is_country_code_supported?(country_code) do
|
||||||
|
true ->
|
||||||
Country.country_module(country_code).incomplete_rule()
|
Country.country_module(country_code).incomplete_rule()
|
||||||
|> parse_bban_by_regex(bban_string)
|
|> parse_bban_by_regex(bban_string)
|
||||||
|
false ->
|
||||||
|
%{}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_bban(bban_string, country_code, _options) do
|
def parse_bban(bban_string, country_code, incomplete: false) do
|
||||||
|
case Country.is_country_code_supported?(country_code) do
|
||||||
|
true ->
|
||||||
Country.country_module(country_code).rule()
|
Country.country_module(country_code).rule()
|
||||||
|> parse_bban_by_regex(bban_string)
|
|> parse_bban_by_regex(bban_string)
|
||||||
|
false ->
|
||||||
|
%{}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp parse_bban_by_regex(_regex, nil), do: %{}
|
defp parse_bban_by_regex(_regex, nil), do: %{}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ def iban_violates_country_rule?(iban) do
|
|||||||
rule <- country_module.rule() do
|
rule <- country_module.rule() do
|
||||||
!Regex.match?(rule, bban)
|
!Regex.match?(rule, bban)
|
||||||
else
|
else
|
||||||
{:error, _error} -> true
|
_ -> true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user