iban-ex/lib/iban_ex/validator/replacements.ex

47 lines
942 B
Elixir
Raw Normal View History

2024-03-05 11:02:58 +00:00
defmodule IbanEx.Validator.Replacements do
@moduledoc """
Replacements in IBANs for checksums calculations
"""
import IbanEx.Commons, only: [normalize: 1]
@type symbol() :: <<_::8>>
@type value() :: <<_::16>>
@type replacements() :: %{symbol() => value()}
@replacements %{
"A" => "10",
"B" => "11",
"C" => "12",
"D" => "13",
"E" => "14",
"F" => "15",
"G" => "16",
"H" => "17",
"I" => "18",
"J" => "19",
"K" => "20",
"L" => "21",
"M" => "22",
"N" => "23",
"O" => "24",
"P" => "25",
"Q" => "26",
"R" => "27",
"S" => "28",
"T" => "29",
"U" => "30",
"V" => "31",
"W" => "32",
"X" => "33",
"Y" => "34",
"Z" => "35"
}
@spec replacements() :: replacements()
def replacements(), do: @replacements
@spec replace(symbol()) :: value()
def replace(symbol), do: @replacements[normalize(symbol)] || normalize(symbol)
end