Fixes in factory and registry validation tests
This commit is contained in:
@@ -179,7 +179,7 @@ test "validates numeric-only BBANs (68 countries, 64.8%)" do
|
|||||||
# Verify they are actually numeric
|
# Verify they are actually numeric
|
||||||
Enum.each(numeric_ibans, fn iban ->
|
Enum.each(numeric_ibans, fn iban ->
|
||||||
{:ok, parsed} = Parser.parse(iban)
|
{:ok, parsed} = Parser.parse(iban)
|
||||||
bban = String.slice(iban, 4..-1//1
|
bban = String.slice(iban, 4..-1//1)
|
||||||
|
|
||||||
assert bban =~ ~r/^\d+$/,
|
assert bban =~ ~r/^\d+$/,
|
||||||
"Expected numeric BBAN for #{parsed.country_code}, got: #{bban}"
|
"Expected numeric BBAN for #{parsed.country_code}, got: #{bban}"
|
||||||
@@ -194,7 +194,7 @@ test "validates alphanumeric BBANs (31+ countries, 29.5%)" do
|
|||||||
|
|
||||||
# Verify they contain letters
|
# Verify they contain letters
|
||||||
Enum.each(alphanumeric_ibans, fn iban ->
|
Enum.each(alphanumeric_ibans, fn iban ->
|
||||||
bban = String.slice(iban, 4..-1//1
|
bban = String.slice(iban, 4..-1//1)
|
||||||
|
|
||||||
assert bban =~ ~r/[A-Z]/,
|
assert bban =~ ~r/[A-Z]/,
|
||||||
"Expected alphanumeric BBAN for #{iban}, got: #{bban}"
|
"Expected alphanumeric BBAN for #{iban}, got: #{bban}"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ defmodule IbanEx.IbanFactory do
|
|||||||
Supports creating valid and invalid IBANs for comprehensive testing.
|
Supports creating valid and invalid IBANs for comprehensive testing.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
alias IbanEx.{Iban, Country}
|
alias IbanEx.Parser
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Build an IBAN struct with custom attributes.
|
Build an IBAN struct with custom attributes.
|
||||||
@@ -104,7 +104,7 @@ def build_with_unsupported_country do
|
|||||||
# Private functions
|
# Private functions
|
||||||
|
|
||||||
defp build_from_string(iban_string) do
|
defp build_from_string(iban_string) do
|
||||||
case IbanEx.parse(iban_string) do
|
case Parser.parse(iban_string) do
|
||||||
{:ok, iban} -> iban
|
{:ok, iban} -> iban
|
||||||
{:error, _} -> raise "Invalid IBAN string: #{iban_string}"
|
{:error, _} -> raise "Invalid IBAN string: #{iban_string}"
|
||||||
end
|
end
|
||||||
@@ -117,7 +117,7 @@ defp build_from_attrs(attrs) do
|
|||||||
example_iban = get_example_iban(country_code)
|
example_iban = get_example_iban(country_code)
|
||||||
|
|
||||||
# Parse it to get the structure
|
# Parse it to get the structure
|
||||||
{:ok, base_iban} = IbanEx.parse(example_iban)
|
{:ok, base_iban} = Parser.parse(example_iban)
|
||||||
|
|
||||||
# Override with provided attributes
|
# Override with provided attributes
|
||||||
%{
|
%{
|
||||||
|
|||||||
Reference in New Issue
Block a user