# `DrivingLicenceNumber`

A driving licence's number, with the country that issued it.

Use it for car hire or motor insurance. To hold any document with its expiry date, use [`IdentityDocument`](/docs/types/type-identity-document.md).

## Shape

| Field | Type | Required? |
|---|---|---|
| `country` | [`Country`](/docs/types/type-country.md) | Yes |
| `number` | `Text` | Yes |

Its parts keep these rules, and a value that breaks one fails with the rule's name:

- `number_of_country`: number is in the form of its country's numbers

## Example

```jadpo
DrivingLicenceNumber { country: Country.gb number: "MCADI801206HZ9HM" }
```

## Good to know

- Write the number in capitals with no spaces. It is checked against the country's form where the country publishes one.
- `text.format` shows only the last four characters.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it, so sort by one of its parts instead.
- A field that holds one counts as personal data (`government_id`), so you don't mark it yourself.

## In JSON

An object of its parts, in a request, a response or `json.write`:

```json
{"country":"GB","number":"MCADI801206HZ9HM"}
{"country":"US","number":"D1234567"}
```

## Details

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

`DrivingLicenceNumber` is in the group Tax and identity numbers, 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 2 columns, each named for the field, `_` and its suffix. This is `{"country":"US","number":"D1234567"}`:

| Column | Type | Holds |
|---|---|---|
| `<field>_country` | `text` | `'US'` |
| `<field>_number` | `text` | `'D1234567'` |

### How it is shown to people

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

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `{"country":"GB","number":"MCADI801206HZ9HM"}` | `•••• Z9HM` |
| `{"country":"US","number":"D1234567"}` | `•••• 4567` |

### 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>
