Spec-Zone.ru › Valibot

slug

Creates an slug validation action.

const Action = v.slug<TInput, TMessage>(message);

Generics

  • TInput extends string
  • TMessage extends ErrorMessage<SlugIssue<TInput>> | undefined

Parameters

  • message TMessage

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

  • Action SlugAction<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

any, custom, string

Methods

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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