maxEntries
Creates a max entries validation action.
const Action = v.maxEntries<TInput, TRequirement, TMessage>(
requirement,
message
);
Generics
TInputextends EntriesInputTRequirementextends numberTMessageextends ErrorMessage<MaxEntriesIssue<TInput, TRequirement>> | undefined
Parameters
requirementTRequirementmessageTMessage
Explanation
With maxEntries 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
ActionMaxEntriesAction<TInput, TRequirement, TMessage>
Examples
The following examples show how maxEntries can be used.
Maximum object entries
Schema to validate an object with a maximum of 5 entries.
const MaxEntriesSchema = v.pipe(
v.record(v.string(), v.number()),
v.maxEntries(5, 'Object must not exceed 5 entries.')
);
Related
The following APIs can be combined with maxEntries.
Schemas
looseObject, object, objectWithRest, record, strictObject, variant
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/maxEntries/