slug
Creates an slug validation action.
const Action = v.slug<TInput, TMessage>(message);
Generics
TInputextends stringTMessageextends ErrorMessage<SlugIssue<TInput>> | undefined
Parameters
messageTMessage
Explanation
With slug you can validate the formatting of a string. If the input is not a URL slug, you can use message to customize the error message.
Returns
ActionSlugAction<TInput, TMessage>
Examples
The following examples show how slug can be used.
Slug schema
Schema to validate a slug.
const SlugSchema = v.pipe(
v.string(),
v.nonEmpty('Please provide a slug.'),
v.slug('The slug is badly formatted.'),
v.maxLength(100, 'Your slug is too long.')
);
Related
The following APIs can be combined with slug.
Schemas
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/slug/