Spec-Zone.ru › Valibot

toString

Creates a to string transformation action.

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

Generics

  • TInput extends any
  • TMessage extends ErrorMessage<ToStringIssue<TInput>> | undefined

Parameters

  • message TMessage

Explanation

With toString you can transform the input to a string. If the input cannot be transformed, you can use message to customize the error message.

Returns

  • Action ToStringAction<TInput, TMessage>

Examples

The following examples show how toString can be used.

String schema

Schema to validate a number and transform it to a string.

const StringSchema = v.pipe(v.number(), v.toString());

Related

The following APIs can be combined with toString.

Schemas

any, bigint, boolean, custom, date, null, number, symbol, undefined, unknown

Methods

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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