# `CountrySubdivision`

A country's subdivision (ISO 3166-2), written as its code, `GB-ENG`, its variant `CountrySubdivision.gb_eng`.

[Places](types.md#places); not ordered; since Jadpo 0.1.0.

## Make one

Pick one of its variants, `CountrySubdivision.ad_02`.

`text.parse(raw, as: CountrySubdivision)` reads one from its text; text that isn't one at all fails `malformed`, such as `GB`, `ENG` or `GB_ENG`.

## Variants

5653 variants. Each is its code in lower case, with `_` for every other character: `CountrySubdivision.ad_02` is written `AD-02`. The first 40: `AD-02`, `AD-03`, `AD-04`, `AD-05`, `AD-06`, `AD-07`, `AD-08`, `AE-AJ`, `AE-AZ`, `AE-DU`, `AE-FU`, `AE-RK`, `AE-SH`, `AE-UQ`, `AF-BAL`, `AF-BAM`, `AF-BDG`, `AF-BDS`, `AF-BGL`, `AF-DAY`, `AF-FRA`, `AF-FYB`, `AF-GHA`, `AF-GHO`, `AF-HEL`, `AF-HER`, `AF-JOW`, `AF-KAB`, `AF-KAN`, `AF-KAP`, `AF-KDZ`, `AF-KHO`, `AF-KNR`, `AF-LAG`, `AF-LOG`, `AF-NAN`, `AF-NIM`, `AF-NUR`, `AF-PAN`, `AF-PAR`.

## Text, JSON and storage

`text.from` writes its canonical text, the one form `text.parse` reads back. JSON sends its canonical text as a string.

| Text | JSON |
|---|---|
| `GB-ENG` | `"GB-ENG"` |
| `JP-13` | `"JP-13"` |
| `US-CA` | `"US-CA"` |

It is stored in one column named for the field, of type `text`. `JP-13` is stored as `'JP-13'`.

## Shown to people

`text.format(value, locale:)` shows it to people in their locale.

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `GB-ENG` | `England` |
| `JP-13` | `Tokyo` |
| `US-CA` | `California` |

## Operations

It has the contract's own operations: `text.parse`, `text.from`, `text.format`, `json.read`, `json.write` and `==`. It isn't ordered, so `<` and sorting don't take it. [Every standard type meets one contract](../topics/every-standard-type-meets-one-contract.md) says how they work.
