digits
Creates a digits validation action.
The difference between
digitsanddecimalis thatdigitsaccepts only the digits 0-9, whiledecimalaccepts floating point numbers and negative numbers.
const Action = v.digits<TInput, TMessage>(message);
Generics
TInputextends stringTMessageextends ErrorMessage<DigitsIssue<TInput>> | undefined
Parameters
messageTMessage
Explanation
With digits you can validate the formatting of a string. If the input does not soley consist of numerical digits, you can use message to customize the error message.
Returns
ActionDigitsAction<TInput, TMessage>
Examples
The following examples show how digits can be used.
Digits schema
Schema to validate a digits.
const DigitsSchema = v.pipe(
v.string(),
v.digits('The string contains something other than digits.')
);
Related
The following APIs can be combined with digits.
Schemas
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/digits/