# `PassportNumber`

A passport's number with the country that issued it (ICAO Doc 9303): the number upper case, in that country's form where it publishes one, `123456789` for the United Kingdom. Shown masked to its last four. Personal data.

[Tax and identity numbers](types.md#tax-and-identity-numbers); not ordered; since Jadpo 0.1.0.

## Make one

Build one from its fields, `PassportNumber { country: ...  number: ... }`.

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

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

## Fields

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

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

| JSON |
|---|
| `{"country":"GB","number":"123456789"}` |
| `{"country":"FR","number":"12AB34567"}` |

It is stored in 2 columns, each named for the field, `_` and its suffix. This is `{"country":"FR","number":"12AB34567"}`:

| Column | Type | Holds |
|---|---|---|
| `<field>_country` | `text` | `'FR'` |
| `<field>_number` | `text` | `'12AB34567'` |

## Shown to people

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

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `{"country":"GB","number":"123456789"}` | `•••• 6789` |
| `{"country":"FR","number":"12AB34567"}` | `•••• 4567` |

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