Skip to content

Function: inList() ​

ts
function inList<T>(values): Validator<T>;

Enum inclusion validation / 枚举包含校验

Type Parameters ​

Type Parameter
T

Parameters ​

ParameterType
valuesreadonly T[]

Returns ​

Validator<T>

Example ​

ts
inList(['a', 'b', 'c'])('b') // => { isValid: true, message: undefined }
inList(['a', 'b', 'c'])('d') // => { isValid: false, message: 'Value is not in the allowed list / 值不在允许的列表中' }

Since ​

1.0.0

Released under the MIT License.