Commons and EDRPOU basic functionality (parser (but complete only), checksum with test coverage)
This commit is contained in:
24
lib/ukraine_taxid_ex/itin/error.ex
Normal file
24
lib/ukraine_taxid_ex/itin/error.ex
Normal file
@@ -0,0 +1,24 @@
|
||||
defmodule UkraineTaxidEx.Itin.Error do
|
||||
@type error() ::
|
||||
:invalid_length
|
||||
| :invalid_checksum
|
||||
| :length_to_long
|
||||
| :length_to_short
|
||||
@type errors() :: [error()]
|
||||
@errors [
|
||||
:invalid_length,
|
||||
:invalid_checksum,
|
||||
:length_to_long,
|
||||
:length_to_short
|
||||
]
|
||||
@messages [
|
||||
invalid_length: "EDRPOU violates the required length",
|
||||
invalid_checksum: "EDRPOU checksum is invalid",
|
||||
length_to_long: "EDRPOU longer then required length",
|
||||
length_to_short: "EDRPOU shorter then required length"
|
||||
]
|
||||
|
||||
@spec message(error()) :: String.t()
|
||||
def message(error) when error in @errors, do: @messages[error]
|
||||
def message(_error), do: "Undefined error"
|
||||
end
|
||||
Reference in New Issue
Block a user