2024-12-11 08:02:07 +00:00
|
|
|
defmodule UkraineTaxidEx.Edrpou.Error do
|
|
|
|
@type error() ::
|
|
|
|
:invalid_length
|
|
|
|
| :invalid_checksum
|
2024-12-12 06:32:31 +00:00
|
|
|
| :length_too_long
|
|
|
|
| :length_too_short
|
2024-12-11 08:02:07 +00:00
|
|
|
@type errors() :: [error()]
|
|
|
|
@errors [
|
|
|
|
:invalid_length,
|
|
|
|
:invalid_checksum,
|
2024-12-12 06:32:31 +00:00
|
|
|
:length_too_long,
|
|
|
|
:length_too_short
|
2024-12-11 08:02:07 +00:00
|
|
|
]
|
|
|
|
@messages [
|
|
|
|
invalid_length: "EDRPOU violates the required length",
|
|
|
|
invalid_checksum: "EDRPOU checksum is invalid",
|
2024-12-12 06:32:31 +00:00
|
|
|
length_too_long: "EDRPOU longer then required length",
|
|
|
|
length_too_short: "EDRPOU shorter then required length"
|
2024-12-11 08:02:07 +00:00
|
|
|
]
|
|
|
|
|
2024-12-12 06:32:31 +00:00
|
|
|
@spec message({:error, error()} | error()) :: String.t()
|
|
|
|
def message({:error, error}) when error in @errors, do: @messages[error]
|
2024-12-11 08:02:07 +00:00
|
|
|
def message(error) when error in @errors, do: @messages[error]
|
|
|
|
def message(_error), do: "Undefined error"
|
|
|
|
end
|