Function: inList()
ts
function inList<T>(values): Validator<T>;Enum inclusion validation / 枚举包含校验
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
values | readonly 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