# `VehicleRegistration`

A vehicle's registration mark with its country, written `GB AB12 CDE`, the mark kept as its plate shows it.

[Commerce and logistics](types.md#commerce-and-logistics); not ordered; since Jadpo 0.1.0.

## Make one

Build one from its fields, `VehicleRegistration { country: ...  plate: ... }`.

`text.parse(raw, as: VehicleRegistration)` reads one from its text; text that isn't one at all fails `malformed`, such as `GB ab12 cde`, `GB AB12  CDE` or `GB AB12-`.

## Fields

| Field | Type |
|---|---|
| `country` | [`Country`](type-country.md) |
| `plate` | `Text` |

## 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 AB12 CDE` | `"GB AB12 CDE"` |
| `DE M-AB 1234` | `"DE M-AB 1234"` |
| `FR AA-123-AA` | `"FR AA-123-AA"` |

It is stored in 2 columns, each named for the field, `_` and its suffix. This is `DE M-AB 1234`:

| Column | Type | Holds |
|---|---|---|
| `<field>_country` | `text` | `'DE'` |
| `<field>_plate` | `text` | `'M-AB 1234'` |

## Shown to people

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

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `GB AB12 CDE` | `GB AB12 CDE` |
| `DE M-AB 1234` | `DE M-AB 1234` |
| `FR AA-123-AA` | `FR AA-123-AA` |

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