# `Yubin`
[🔗](https://github.com/NexPB/yubin/blob/v0.1.0/lib/yubin.ex#L1)

Japanese postal code lookup, with data bundled from Japan Post.

# `data_version`

```elixir
@spec data_version() :: Date.t()
```

Returns the date of the Japan Post data bundled with this version.

# `lookup`

```elixir
@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`.

# `normalize`

```elixir
@spec normalize(term()) :: {:ok, String.t()} | {:error, :invalid}
```

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("〒５３０ー０００１")
    {:ok, "530-0001"}

    iex> Yubin.normalize("530-001")
    {:error, :invalid}

# `prefectures`

```elixir
@spec prefectures() :: [Yubin.Prefecture.t()]
```

Returns the 47 prefectures in JIS order.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
