minEntries
Creates a min entries validation action.
const Action = v.minEntries<TInput, TRequirement, TMessage>(
requirement,
message
);
Generics
TInputextends EntriesInputTRequirementextends numberTMessageextends ErrorMessage<MinEntriesIssue<TInput, TRequirement>> | undefined
Parameters
requirementTRequirementmessageTMessage
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
ActionMinEntriesAction<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
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/minEntries/