Spec-Zone.ru › Valibot

title

Creates a title metadata action.

const Action = v.title<TInput, TTitle>(title_);

Generics

  • TInput extends any
  • TTitle extends string

Parameters

  • title_ TTitle

Explanation

With title you can give a title to a schema. This can be useful when working with AI tools or for documentation purposes.

Returns

  • Action TitleAction<TInput, TTitle>

Examples

The following examples show how title can be used.

Username schema

Schema to validate a user name.

const UsernameSchema = v.pipe(
  v.string(),
  v.regex(/^[a-z0-9_-]{4,16}$/iu),
  v.title('Username'),
  v.description(
    'A username must be between 4 and 16 characters long and can only contain letters, numbers, underscores and hyphens.'
  )
);

Related

The following APIs can be combined with title.

Schemas

any, array, bigint, blob, boolean, custom, date, enum, exactOptional, file, function, instance, intersect, lazy, literal, looseObject, looseTuple, map, nan, never, nonNullable, nonNullish, nonOptional, null, nullable, nullish, number, object, objectWithRest, optional, picklist, promise, record, set, strictObject, strictTuple, string, symbol, tuple, tupleWithRest, undefined, undefinedable, union, unknown, variant, void

Methods

getTitle, pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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