multipleOf
Creates a multiple of validation action.
const Action = v.multipleOf<TInput, TRequirement, TMessage>(
requirement,
message
);
Generics
TInputextends number | bigintTRequirementextends number | bigintTMessageextends ErrorMessage<MultipleOfIssue<TInput, TRequirement>> | undefined
Parameters
requirementTRequirementmessageTMessage
Explanation
With multipleOf you can validate the value of a number. If the input does not match the requirement, you can use message to customize the error message.
Returns
ActionMultipleOfAction<TInput, TRequirement, TMessage>
Examples
The following examples show how multipleOf can be used.
Even number schema
Schema to validate an even number.
const EvenNumberSchema = v.pipe(
v.number(),
v.multipleOf(2, 'The number must be even.')
);
Related
The following APIs can be combined with multipleOf.
Schemas
any, bigint, custom, number, unknown
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/multipleOf/