From f66cdc0d19d49ec931efa95c2380aabfa092f7b2 Mon Sep 17 00:00:00 2001 From: Danylo Negrienko Date: Tue, 2 Dec 2025 10:12:07 -0500 Subject: [PATCH] Implement normalization of empty strings to nil in parser.ex --- lib/iban_ex/parser.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/iban_ex/parser.ex b/lib/iban_ex/parser.ex index 8d6b73f..6ce1478 100644 --- a/lib/iban_ex/parser.ex +++ b/lib/iban_ex/parser.ex @@ -108,13 +108,16 @@ defp parse_bban_by_regex(regex, bban_string) do map when is_map(map) -> for {key, val} <- map, into: %{}, - do: {String.to_atom(key), val} + do: {String.to_atom(key), normalize_empty_to_nil(val)} nil -> %{} 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() def country_code(iban_string), do: normalize_and_slice(iban_string, 0..1)