# `PaymentCardNumber`

A payment card's full number, checked by its check digit.

Use it only for the moment you pass a number on to a payment provider. To keep something about a card, use [`MaskedCardNumber`](/docs/types/type-masked-card-number.md), which `money.mask` makes from this one.

## Shape

One value, held as text in one set form, with no parts: `5555555555554444`.

## Example

```jadpo
PaymentCardNumber("4242424242424242")
```

`PaymentCardNumber(raw)` checks the text, and text that isn't one breaks the `format` rule.

`text.parse(raw, as: PaymentCardNumber)` reads one from text that comes from outside. Text that isn't one at all fails `malformed`, such as `4242424242424241`, `4242 4242 4242 4242` or `42424242424`.

## Good to know

- `text.format` shows only the last four digits: `•••• 4242`.
- Write it with no spaces. Remove any a person types before you build one.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it.
- A field that holds one counts as personal data (`financial`), so you don't mark it yourself.

## In JSON

A string, in a request, a response or `json.write`:

```json
"4242424242424242"
"378282246310005"
"5555555555554444"
```

## Details

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

`PaymentCardNumber` is in the group Money and banking, and has been in Jadpo since 0.1.0.

### Text form

`text.from` writes one standard text form, the same form `text.parse` reads back: `4242424242424242`, `378282246310005` and `5555555555554444`.

### How it is stored

It is stored in one column named for the field, of type `text`. `378282246310005` is stored as `'378282246310005'`.

### How it is shown to people

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

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `4242424242424242` | `•••• 4242` |
| `378282246310005` | `•••• 0005` |
| `5555555555554444` | `•••• 4444` |

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

It also takes `text.parse`, `text.from`, `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>
