Spec-Zone.ru › Valibot

digits

Creates a digits validation action.

The difference between digits and decimal is that digits accepts only the digits 0-9, while decimal accepts floating point numbers and negative numbers.

const Action = v.digits<TInput, TMessage>(message);

Generics

  • TInput extends string
  • TMessage extends ErrorMessage<DigitsIssue<TInput>> | undefined

Parameters

  • message TMessage

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

  • Action DigitsAction<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

any, custom, string

Methods

pipe

Utils

isOfKind, isOfType

© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/digits/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API