# oneOf

> Value must strict-equal one of the whitelisted options. Empty values pass.

Source: https://ngwr.dev/reference/validators/one-of  
Kind: Validator

## Live demo

Try `xs`, `sm`, `md`, `lg`, or `xl` — anything else fails.

## Usage

```angular-ts
import { FormControl } from '@angular/forms';
import { WrValidators } from 'ngwr/validators';

const size = new FormControl('', [
  WrValidators.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
]);
```

## Why ngwr provides this

Whitelist checks via `Validators.pattern` mean escaping every alternative into a regex. This takes the allowed values as plain data.

## API

| Name | Description | Type | Default |
| --- | --- | --- | --- |
| `signature` | Factory — call with the whitelist. | `<T>(allowed: readonly T[]) => ValidatorFn` | `—` |
| `comparison` | Strict `===`. Pass a typed const tuple to keep the union narrow on the consumer side. | `—` | `—` |
| `error key` | On failure: `{ oneOf: { allowed: [...] } }`. Empty value passes. | `{ oneOf: { allowed } }` | `—` |

## See also

- [wr-select](https://ngwr.dev/reference/components/select) — Constrained choice control - validate free input against its options.
- [wr-segmented](https://ngwr.dev/reference/components/segmented) — Inline single-choice alternative.
