# `Allergen`

One of the 14 allergens a UK or EU food label must name: `milk`, `celery` and so on.

Use it to mark what's in a dish or a product. For a person's own allergy to something else, use your own type, since this list holds only those 14.

## Shape

One of these 14 values:

`Allergen.celery`, `Allergen.cereals_containing_gluten`, `Allergen.crustaceans`, `Allergen.eggs`, `Allergen.fish`, `Allergen.lupin`, `Allergen.milk`, `Allergen.molluscs`, `Allergen.mustard`, `Allergen.peanuts`, `Allergen.sesame`, `Allergen.soybeans`, `Allergen.sulphites`, `Allergen.tree_nuts`.

## Example

```jadpo
Allergen.milk
```

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

## Good to know

- `Allergen.cereals_containing_gluten` is the name for gluten. `text.format` shows the UK Food Standards Agency's wording.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it.

## In JSON

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

```json
"cereals_containing_gluten"
"milk"
"sulphites"
```

## Details

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

`Allergen` is in the group Health, 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: `cereals_containing_gluten`, `milk` and `sulphites`.

### How it is stored

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

### How it is 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 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>
