# `TaxId`

A taxpayer's identification number with the country that issued it, as the OECD's common reporting standard records one: any of that country's forms, a UTR or a National Insurance number 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, `TaxId { 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":"AB123456C"}` |
| `{"country":"US","number":"123456789"}` |

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

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

## Shown to people

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

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `{"country":"GB","number":"AB123456C"}` | `•••• 456C` |
| `{"country":"US","number":"123456789"}` | `•••• 6789` |

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