Spec-Zone.ru › Valibot

notValues

Creates a not values validation action.

const Action = v.notValues<TInput, TRequirement, TMessage>(
  requirement,
  message
);

Generics

  • TInput extends ValueInput
  • TRequirement extends readonly TInput[]
  • TMessage extends ErrorMessage<NotValuesIssue<TInput, TRequirement>> | undefined

Parameters

  • requirement TRequirement
  • message TMessage

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

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

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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