Skip to main content
Version: 0.1.1

Function: oneOf()

Imported from @react-logic/utils

oneOf<T, N>(values, message?, name?): ValidatorEntry<T> & object

Value must be one of the provided literals. Useful for select / radio fields where the schema doesn't already constrain the type.

Type Parameters​

T​

T

N​

N extends string = "oneOf"

Parameters​

values​

readonly T[]

message?​

string = 'Invalid choice'

name?​

N = ...

Returns​

ValidatorEntry<T> & object