# `MaskedCardNumber`

What may be kept of a payment card once its number is gone (PCI DSS): its brand, where a listed scheme issued it, and its last four digits, shown as `Visa •••• 4242`. `money.mask` makes one from a `PaymentCardNumber`. Personal data.

[Money and banking](types.md#money-and-banking); not ordered; since Jadpo 0.1.0.

## Make one

Build one from its fields, `MaskedCardNumber { last_four: ... }`.

This operation gives one: `money.mask`.

## Fields

| Field | Type |
|---|---|
| `brand` | [`CardBrand`](type-card-brand.md)`?` |
| `last_four` | `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 |
|---|
| `{"brand":"visa","last_four":"4242"}` |
| `{"brand":"american_express","last_four":"0005"}` |
| `{"brand":null,"last_four":"1234"}` |

It is stored in 2 columns, each named for the field, `_` and its suffix. This is `{"brand":"american_express","last_four":"0005"}`:

| Column | Type | Holds |
|---|---|---|
| `<field>_brand` | `text` | `'american_express'` |
| `<field>_last_four` | `text` | `'0005'` |

## Shown to people

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

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `{"brand":"visa","last_four":"4242"}` | `Visa •••• 4242` |
| `{"brand":"american_express","last_four":"0005"}` | `American Express •••• 0005` |
| `{"brand":null,"last_four":"1234"}` | `•••• 1234` |

## Operations

- `money.mask(card: PaymentCardNumber) -> MaskedCardNumber`: What may be kept of `card` once its number is gone: its brand, told by its first digits from the ranges each scheme publishes (`none` for a range no listed scheme issues), and its last four digits.

Like every standard type, it also 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.
