# `Jurisdiction`

Where a law applies: a country, or a part of one such as England.

Use it for where a rule or a licence applies. For where something is, use [`Country`](/docs/types/type-country.md) or [`CountrySubdivision`](/docs/types/type-country-subdivision.md) on their own.

## Shape

One of these, each with its own fields:

| Variant | Field | Type | Required? |
|---|---|---|---|
| `Jurisdiction.country` | `country` | [`Country`](/docs/types/type-country.md) | Yes |
| `Jurisdiction.subdivision` | `subdivision` | [`CountrySubdivision`](/docs/types/type-country-subdivision.md) | Yes |

## Example

```jadpo
Jurisdiction.subdivision { subdivision: CountrySubdivision.gb_eng }
```

## Good to know

- The other variant is `Jurisdiction.country { country: ... }`.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it.

## In JSON

An object of its variant's name, as `tag`, and the variant's fields, in a request, a response or `json.write`:

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

## Details

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

`Jurisdiction` is in the group Other with a published standard, and has been in Jadpo since 0.1.0.

### Text form

It has no single text form, so `text.from` and `text.parse` don't take it.

### How it is stored

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'` |

### How it is 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 also takes `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>
