Check to existing country module before parsing bban
This commit is contained in:
parent
ce90960649
commit
5cfc3f5fa2
|
@ -45,13 +45,23 @@ defmodule IbanEx.Parser 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
|
||||||
Country.country_module(country_code).incomplete_rule()
|
case Country.is_country_code_supported?(country_code) do
|
||||||
|> parse_bban_by_regex(bban_string)
|
true ->
|
||||||
|
Country.country_module(country_code).incomplete_rule()
|
||||||
|
|> 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
|
||||||
Country.country_module(country_code).rule()
|
case Country.is_country_code_supported?(country_code) do
|
||||||
|> parse_bban_by_regex(bban_string)
|
true ->
|
||||||
|
Country.country_module(country_code).rule()
|
||||||
|
|> 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: %{}
|
||||||
|
|
Loading…
Reference in New Issue