Japanese postal code lookup, with data bundled from Japan Post.
Summary
Functions
Returns the date of the Japan Post data bundled with this version.
Returns the addresses of a postal code.
Returns the postal code in the form "NNN-NNNN", or {:error, :invalid} when the input is not one.
Returns the 47 prefectures in JIS order.
Functions
@spec data_version() :: Date.t()
Returns the date of the Japan Post data bundled with this version.
@spec lookup(term()) :: {:ok, [Yubin.Address.t(), ...]} | {:error, :not_found | :invalid}
Returns the addresses of a postal code.
Accepts the input forms of normalize/1. {:error, :not_found} can mean a code newer
than the bundled data, see data_version/0.
Returns the postal code in the form "NNN-NNNN", or {:error, :invalid} when the input is not one.
The input is 7 digits with an optional hyphen after the third. Full-width characters,
any hyphen or dash, a leading 〒 and spaces are accepted.
iex> Yubin.normalize("〒530ー0001")
{:ok, "530-0001"}
iex> Yubin.normalize("530-001")
{:error, :invalid}
@spec prefectures() :: [Yubin.Prefecture.t()]
Returns the 47 prefectures in JIS order.