2 Commits

Author SHA1 Message Date
ce90960649 iban_violates_country_rule? fix 2024-05-14 23:55:32 -04:00
e7e6bbda29 Return blank strings in responses 2024-05-14 23:45:34 -04:00
2 changed files with 6 additions and 6 deletions

View File

@@ -2,7 +2,7 @@ defmodule IbanEx.Parser do
@moduledoc false
alias IbanEx.{Country, Iban, Validator}
import IbanEx.Commons, only: [normalize_and_slice: 2, blank: 1]
import IbanEx.Commons, only: [normalize_and_slice: 2]
@type iban_string() :: String.t()
@type country_code_string() :: <<_::16>>
@@ -60,7 +60,7 @@ defp parse_bban_by_regex(regex, bban_string) do
map when is_map(map) ->
for {key, val} <- map,
into: %{},
do: {String.to_atom(key), blank(val)}
do: {String.to_atom(key), val}
nil ->
%{}
@@ -68,11 +68,11 @@ defp parse_bban_by_regex(regex, bban_string) do
end
@spec country_code(iban_string()) :: country_code_string()
def country_code(iban_string), do: normalize_and_slice(iban_string, 0..1) |> blank()
def country_code(iban_string), do: normalize_and_slice(iban_string, 0..1)
@spec check_digits(binary()) :: check_digits_string()
def check_digits(iban_string), do: normalize_and_slice(iban_string, 2..3) |> blank()
def check_digits(iban_string), do: normalize_and_slice(iban_string, 2..3)
@spec bban(binary()) :: binary()
def bban(iban_string), do: normalize_and_slice(iban_string, 4..-1//1) |> blank()
def bban(iban_string), do: normalize_and_slice(iban_string, 4..-1//1)
end

View File

@@ -123,7 +123,7 @@ def iban_violates_country_rule?(iban) do
rule <- country_module.rule() do
!Regex.match?(rule, bban)
else
{:error, _error} -> true
_ -> true
end
end