# `CountrySubdivision`

A state, province or other part of a country, written as its code: `GB-ENG`, `US-CA`.

Use it when you need to know the region for certain, such as for state sales tax. An address's `region` is free text, so use this type only when you want a checked list. For the whole country, use [`Country`](/docs/types/type-country.md).

## Shape

One of 5653 values, such as `CountrySubdivision.ad_02`, written `AD-02`. Details has them.

## Example

```jadpo
CountrySubdivision.us_ca
```

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

## Good to know

- The name is the code in lower case with `_` for `-`: `CountrySubdivision.gb_eng`.
- The list comes from ISO 3166-2. It has over 5,000 values, so look a code up there, or use `jadpo help CountrySubdivision --json` and search.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it.

## In JSON

A string, in a request, a response or `json.write`:

```json
"GB-ENG"
"JP-13"
"US-CA"
```

## Details

<details>
<summary>Text form, storage, how it is shown, and operations</summary>

`CountrySubdivision` is in the group Places, and has been in Jadpo since 0.1.0.

### Every value

The first 40 of 5653; `jadpo help CountrySubdivision --json` lists every one:

`ad_02` (`AD-02`), `ad_03` (`AD-03`), `ad_04` (`AD-04`), `ad_05` (`AD-05`), `ad_06` (`AD-06`), `ad_07` (`AD-07`), `ad_08` (`AD-08`), `ae_aj` (`AE-AJ`), `ae_az` (`AE-AZ`), `ae_du` (`AE-DU`), `ae_fu` (`AE-FU`), `ae_rk` (`AE-RK`), `ae_sh` (`AE-SH`), `ae_uq` (`AE-UQ`), `af_bal` (`AF-BAL`), `af_bam` (`AF-BAM`), `af_bdg` (`AF-BDG`), `af_bds` (`AF-BDS`), `af_bgl` (`AF-BGL`), `af_day` (`AF-DAY`), `af_fra` (`AF-FRA`), `af_fyb` (`AF-FYB`), `af_gha` (`AF-GHA`), `af_gho` (`AF-GHO`), `af_hel` (`AF-HEL`), `af_her` (`AF-HER`), `af_jow` (`AF-JOW`), `af_kab` (`AF-KAB`), `af_kan` (`AF-KAN`), `af_kap` (`AF-KAP`), `af_kdz` (`AF-KDZ`), `af_kho` (`AF-KHO`), `af_knr` (`AF-KNR`), `af_lag` (`AF-LAG`), `af_log` (`AF-LOG`), `af_nan` (`AF-NAN`), `af_nim` (`AF-NIM`), `af_nur` (`AF-NUR`), `af_pan` (`AF-PAN`), `af_par` (`AF-PAR`).

### Text form

`text.from` writes one standard text form, the same form `text.parse` reads back: `GB-ENG`, `JP-13` and `US-CA`.

### How it is stored

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

### How it is 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 also takes `text.parse`, `text.from`, `text.format`, `json.read`, `json.write` and `==`. [How every standard type behaves](/docs/every-standard-type-meets-one-contract.md) says how they work.

</details>
