CHOICE()function
CHOICE(options: PossibleChoiceOptions<K>): ChoiceSchema<K>
| Param | Type | |
|---|---|---|
options | PossibleChoiceOptions<K> | The allowed choices, as a { key: title } dictionary or an array of keys. required |
| Return | |
|---|---|
ChoiceSchema<K> | Schema that validates a value against a fixed set of allowed string choices. |
Create a schema for a valid choice from an allowed set of values.
Sugar factory for ChoiceSchema.
Examples
CHOICE({ yes: "Yes", no: "No" }) // ChoiceSchema<"yes" | "no">