Spec-Zone.ru › Valibot

notEntries

Creates a not entries validation action.

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

Generics

  • TInput extends EntriesInput
  • TRequirement extends number
  • TMessage extends ErrorMessage<NotEntriesIssue<TInput, TRequirement>> | undefined

Parameters

  • requirement TRequirement
  • message TMessage

Explanation

With notEntries you can validate the number of entries of an object. If the input does not match the requirement, you can use message to customize the error message.

Returns

  • Action NotEntriesAction<TInput, TRequirement, TMessage>

Examples

The following examples show how notEntries can be used.

Not object entries

Schema to validate an object that does not have 5 entries.

const NotEntriesSchema = v.pipe(
  v.record(v.string(), v.number()),
  v.notEntries(5, 'Object must not have 5 entries')
);

Related

The following APIs can be combined with notEntries.

Schemas

looseObject, object, objectWithRest, record, strictObject, variant

Methods

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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