toString
Creates a to string transformation action.
const Action = v.toString<TInput, TMessage>(message);
Generics
TInputextends anyTMessageextends ErrorMessage<ToStringIssue<TInput>> | undefined
Parameters
messageTMessage
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
ActionToStringAction<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
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/toString/