Spec-Zone.ru › Valibot

description

Creates a description metadata action.

const Action = v.description<TInput, TDescription>(description_);

Generics

  • TInput extends any
  • TDescription extends string

Parameters

  • description_ TDescription

Explanation

With description you can describe the purpose of a schema. This can be useful when working with AI tools or for documentation purposes.

Returns

  • Action DescriptionAction<TInput, TDescription>

Examples

The following examples show how description 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 description.

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

getDescription, pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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