kkempin / exiban

Elixir library for validation and manipulating IBAN bank account numbers.
MIT License
10 stars 11 forks source link

Improve IBAN validation #9

Closed eltonplima closed 1 year ago

eltonplima commented 1 year ago

The following error was raised:

  1) test parse returns error when receive single char as parameter (ExIban.ParserTest)
     test/parser_test.exs:5
     ** (FunctionClauseError) no function clause matching in String.slice/3

     The following arguments were given to String.slice/3:

         # 1
         "-"

         # 2
         4

         # 3
         -3

     Attempted function clauses (showing 3 out of 3):

         def slice(_, _, 0)
         def slice(string, start, length) when is_binary(string) and is_integer(start) and is_integer(length) and start >= 0 and length >= 0
         def slice(string, start, length) when is_binary(string) and is_integer(start) and is_integer(length) and start < 0 and length >= 0

     code: {:error, :invalid_iban} = ExIban.Parser.parse("-")
     stacktrace:
       (elixir 1.14.2) lib/string.ex:2111: String.slice/3
       (exiban 0.0.6) lib/exiban/parser.ex:23: ExIban.Parser.parse/1
       test/parser_test.exs:6: (test)