decimal
Creates a decimal validation action.
The difference between
decimalanddigitsis thatdecimalaccepts floating point numbers and negative numbers, whiledigitsaccepts only the digits 0-9.
const Action = v.decimal<TInput, TMessage>(message);
Generics
TInputextends stringTMessageextends ErrorMessage<DecimalIssue<TInput>> | undefined
Parameters
messageTMessage
Explanation
With decimal you can validate the formatting of a string. If the input is not a decimal, you can use message to customize the error message.
Returns
ActionDecimalAction<TInput, TMessage>
Examples
The following examples show how decimal can be used.
Decimal schema
Schema to validate a decimal.
const DecimalSchema = v.pipe(
v.string(),
v.decimal('The decimal is badly formatted.')
);
Related
The following APIs can be combined with decimal.
Schemas
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/decimal/