Length checks added, validations added

This commit is contained in:
2024-05-10 17:56:29 -04:00
parent 51c5c1d800
commit 4447a10bf2
6 changed files with 144 additions and 71 deletions

View File

@@ -1,6 +1,7 @@
defmodule IbanExTest do
alias IbanEx.{Country, Iban, Parser}
use ExUnit.Case, async: true
doctest_file "README.md"
doctest IbanEx.Country.AT
doctest IbanEx.Country.BE
doctest IbanEx.Country.BG

View File

@@ -0,0 +1,18 @@
defmodule IbanExValidatorTest do
alias IbanEx.{Validator}
use ExUnit.Case, async: true
test "check IBANs length" do
cases = [
{"FG2112345CC6000007", {:error, :unsupported_country_code}},
{"UK2112345CC6000007", {:error, :unsupported_country_code}},
{"FI2112345CC6000007", :ok},
{"FI2112345CC6000007a", {:error, :length_to_long}},
{"FI2112345CC600007", {:error, :length_to_short}}
]
Enum.all?(cases, fn {iban, result} ->
assert Validator.check_iban_length(iban) == result
end)
end
end