minGraphemes
Creates a min graphemes validation action.
const Action = v.minGraphemes<TInput, TRequirement, TMessage>(
requirement,
message
);
Generics
TInputextends stringTRequirementextends numberTMessageextends ErrorMessage<MinGraphemesIssue<TInput, TRequirement>> | undefined
Parameters
requirementTRequirementmessageTMessage
Explanation
With minGraphemes you can validate the graphemes of a string. If the input does not match the requirement, you can use message to customize the error message.
If you are looking for an equivalent of JavaScript's
.lengthfor minimum length checks, useminLengthinstead. If you need to count each Unicode code point as a single character (a supplementary code point occupies two UTF-16 code units in JavaScript), useminCodePointsinstead.
Returns
ActionMinGraphemesAction<TInput, TRequirement, TMessage>
Examples
The following examples show how minGraphemes can be used.
Min graphemes schema
Schema to validate a string with a minimum of 8 graphemes.
const MinGraphemesSchema = v.pipe(
v.string(),
v.minGraphemes(8, 'The string must contain at least 8 graphemes.')
);
Related
The following APIs can be combined with minGraphemes.
Schemas
Methods
Actions
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/minGraphemes/