# `Jurisdiction`

Where a law applies (ISO 3166): a country or one of its subdivisions. Shown by its name: `England`.

[Other with a published standard](types.md#other-with-a-published-standard); not ordered; since Jadpo 0.1.0.

## Make one

Pick one of its variants and give its fields, `Jurisdiction.country { country: ... }`.

## Variants

| Variant | Fields |
|---|---|
| `country` | `country`: [`Country`](type-country.md) |
| `subdivision` | `subdivision`: [`CountrySubdivision`](type-country-subdivision.md) |

## Text, JSON and storage

It has no single text form, so `text.from` and `text.parse` don't take it. JSON sends an object of its variant's name, as `tag`, and the variant's fields.

| JSON |
|---|
| `{"tag":"country","country":"GB"}` |
| `{"tag":"subdivision","subdivision":"GB-ENG"}` |
| `{"tag":"subdivision","subdivision":"US-CA"}` |

It is stored in 3 columns, each named for the field, `_` and its suffix. This is `{"tag":"subdivision","subdivision":"GB-ENG"}`:

| Column | Type | Holds |
|---|---|---|
| `<field>_kind` | `text` | `'subdivision'` |
| `<field>_country` | `text` | `NULL::text` |
| `<field>_subdivision` | `text` | `'GB-ENG'` |

## Shown to people

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

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `{"tag":"country","country":"GB"}` | `United Kingdom` |
| `{"tag":"subdivision","subdivision":"GB-ENG"}` | `England` |
| `{"tag":"subdivision","subdivision":"US-CA"}` | `California` |

## Operations

It has the contract's own operations: `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.
