Implement normalization of empty strings to nil in parser.ex
This commit is contained in:
@@ -108,13 +108,16 @@ defp parse_bban_by_regex(regex, bban_string) do
|
|||||||
map when is_map(map) ->
|
map when is_map(map) ->
|
||||||
for {key, val} <- map,
|
for {key, val} <- map,
|
||||||
into: %{},
|
into: %{},
|
||||||
do: {String.to_atom(key), val}
|
do: {String.to_atom(key), normalize_empty_to_nil(val)}
|
||||||
|
|
||||||
nil ->
|
nil ->
|
||||||
%{}
|
%{}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp normalize_empty_to_nil(""), do: nil
|
||||||
|
defp normalize_empty_to_nil(val), do: val
|
||||||
|
|
||||||
@spec country_code(iban_string()) :: country_code_string()
|
@spec country_code(iban_string()) :: country_code_string()
|
||||||
def country_code(iban_string), do: normalize_and_slice(iban_string, 0..1)
|
def country_code(iban_string), do: normalize_and_slice(iban_string, 0..1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user