Spec-Zone.ru › Valibot

symbol

Creates a symbol schema.

const Schema = v.symbol<TMessage>(message);

Generics

  • TMessage extends ErrorMessage<SymbolIssue> | undefined

Parameters

  • message TMessage

Explanation

With symbol you can validate the data type of the input. If it is not a symbol, you can use message to customize the error message.

Returns

  • Schema SymbolSchema<TMessage>

Examples

The following examples show how symbol can be used.

Custom message

Symbol schema with a custom error message.

const schema = v.symbol('A symbol is required');

Related

The following APIs can be combined with symbol.

Schemas

array, exactOptional, intersect, lazy, looseObject, looseTuple, map, nonNullable, nonNullish, nonOptional, nullable, nullish, object, objectWithRest, optional, record, set, strictObject, strictTuple, tuple, tupleWithRest, undefinedable, union

Methods

assert, config, fallback, getDefault, getDefaults, getFallback, getFallbacks, is, message, parse, parser, pipe, safeParse, safeParser

Actions

check, brand, description, flavor, guard, metadata, rawCheck, rawTransform, readonly, title, transform

Utils

entriesFromList, isOfKind, isOfType

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

Spec-Zone.ru

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