# `Allergen`

One of the 14 allergens a food label must name (UK FIR 2014 and EU Regulation 1169/2011, Annex II), written as its own name, `milk`, and shown as the Food Standards Agency words it.

[Health](types.md#health); not ordered; since Jadpo 0.1.0.

## Make one

Pick one of its variants, `Allergen.celery`.

`text.parse(raw, as: Allergen)` reads one from its text; text that isn't one at all fails `malformed`, such as `gluten`, `nuts` or `Cereals containing gluten`.

## Variants

14 variants, each written as its own name: `celery`, `cereals_containing_gluten`, `crustaceans`, `eggs`, `fish`, `lupin`, `milk`, `molluscs`, `mustard`, `peanuts`, `sesame`, `soybeans`, `sulphites`, `tree_nuts`.

## Text, JSON and storage

`text.from` writes its canonical text, the one form `text.parse` reads back. JSON sends its canonical text as a string.

| Text | JSON |
|---|---|
| `cereals_containing_gluten` | `"cereals_containing_gluten"` |
| `milk` | `"milk"` |
| `sulphites` | `"sulphites"` |

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

## Shown to people

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

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `cereals_containing_gluten` | `Cereals containing gluten` |
| `milk` | `Milk` |
| `sulphites` | `Sulphur dioxide and sulphites` |

## Operations

It has the contract's own operations: `text.parse`, `text.from`, `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.
