notValues
Creates a not values validation action.
const Action = v.notValues<TInput, TRequirement, TMessage>(
requirement,
message
);
Generics
TInputextends ValueInputTRequirementextends readonly TInput[]TMessageextends ErrorMessage<NotValuesIssue<TInput, TRequirement>> | undefined
Parameters
requirementTRequirementmessageTMessage
Explanation
With notValues you can validate the value of a string, number, boolean or date. If the input matches one of the values in the requirement, you can use message to customize the error message.
Returns
ActionNotValuesAction<TInput, TRequirement, TMessage>
Examples
The following examples show how notValues can be used.
Number schema
Schema to validate a number that is not 10, 11 or 12.
const NumberSchema = v.pipe(
v.number(),
v.notValues([10, 11, 12], 'The number must not be 10, 11 or 12.')
);
Related
The following APIs can be combined with notValues.
Schemas
any, bigint, boolean, custom, date, number, string, unknown
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/notValues/