Spec-Zone.ru › Valibot

minEntries

Creates a min entries validation action.

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

Generics

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

Parameters

  • requirement TRequirement
  • message TMessage

Explanation

With minEntries 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 MinEntriesAction<TInput, TRequirement, TMessage>

Examples

The following examples show how minEntries can be used.

Minimum object entries

Schema to validate an object with a minimum of 5 entries.

const MinEntriesSchema = v.pipe(
  v.record(v.string(), v.number()),
  v.minEntries(5, 'The object should have at least 5 entries.')
);

Related

The following APIs can be combined with minEntries.

Schemas

looseObject, object, objectWithRest, record, strictObject, variant

Methods

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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