# `AddressInput.Country`
[🔗](https://github.com/nkezhaya/address_input/blob/main/lib/address_input/country.ex#L1)

Country metadata parsed from the libaddressinput dataset.

## Fields

- `id` - ISO 3166-1 alpha-2 code.
- `name` - localized display name from the dataset.
- `default_language` - language code used for labels.
- `required_fields` - list of required address components as atoms, derived
  from the dataset codes (`N`, `O`, `A`, `D`, `C`, `S`, `Z`, `X`).
- `subregions` - list of [Subregion](`AddressInput.Subregion`) entries.
- `sublocality_type` - label hint for the city-level field when present.
- `subregion_type` - label hint for the region/state field when present.
- `postal_code_type` - label hint for the postal code field when present.
- `postal_code_regex` - compiled regex for validating postal codes.
- `address_format` - parsed formatting template from the dataset (`fmt`).
- `local_address_format` - parsed local formatting template (`lfmt`) when present.

## Format tokens

The `address_format` fields store a tokenized representation of the raw
template string. You can inspect the tokens to build rendering or validation
helpers without re-parsing the source template.

The token list preserves the order of the original template and contains one
of:

- `{:field, field}` - an address component present in the format, where
  `field` is one of the `AddressInput.Country.field()` atoms. Required fields
  are listed separately in `required_fields`.
- `{:text, string}` - literal text from the template.
- `:newline` - a line break marker (the `%n` code in the dataset).

Unknown format codes raise at parse time to surface dataset issues early.

# `field`

```elixir
@type field() ::
  :name
  | :organization
  | :address
  | :dependent_locality
  | :sublocality
  | :region
  | :postal_code
  | :sorting_code
```

# `t`

```elixir
@type t() :: %AddressInput.Country{
  address_format: AddressInput.address_format(),
  default_language: String.t(),
  id: String.t(),
  local_address_format: AddressInput.address_format() | nil,
  name: String.t(),
  postal_code_regex: Regex.t() | nil,
  postal_code_type: String.t() | nil,
  required_fields: [field()],
  sublocality_type: String.t() | nil,
  subregion_type: String.t() | nil,
  subregions: [AddressInput.Subregion.t()]
}
```

---

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