Live demo
Try xs, sm, md, lg, or xl — anything else fails.
Usage
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 } } | — |