# `CardExpiry`

The month a payment card runs to, written `2028-12`.

Use it beside a card's details on a payment form. For any other month, use [`YearMonth`](/docs/types/type-year-month.md).

## Shape

| Field | Type | Required? |
|---|---|---|
| `year` | `Int` | Yes |
| `month` | `Int` | Yes |

## Example

```jadpo
CardExpiry { year: 2028 month: 12 }
```

`text.parse(raw, as: CardExpiry)` reads one from text that comes from outside. Text that isn't one at all fails `malformed`, such as `12/28`, `2028-13` or `2028-00`.

## Good to know

- `text.format` shows it as a card prints it, `12/28`, but `text.parse` reads only `2028-12`.
- The card is good until the end of that month.
- `==` tells you whether two are the same, and `<` and `list.sort_by` compare and sort them.
- 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
"2026-12"
"2028-01"
```

## Details

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

`CardExpiry` 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: `2026-12` and `2028-01`.

### How it is stored

It is stored in 2 columns, each named for the field, `_` and its suffix. This is `2028-01`:

| Column | Type | Holds |
|---|---|---|
| `<field>_year` | `integer` | `2028` |
| `<field>_month` | `integer` | `1` |

### How it is shown to people

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

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `2026-12` | `12/26` |
| `2028-01` | `01/28` |

### Operations

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>
