toDate
Creates a to date transformation action.
const Action = v.toDate<TInput, TMessage>(message);
Generics
TInputextends anyTMessageextends ErrorMessage<ToDateIssue<TInput>> | undefined
Parameters
messageTMessage
Explanation
With toDate you can transform the input to a date. If the input cannot be transformed, you can use message to customize the error message.
Returns
ActionToDateAction<TInput, TMessage>
Examples
The following examples show how toDate can be used.
Date schema
Schema to validate a string and transform it to a date.
const DateSchema = v.pipe(v.string(), v.toDate());
Related
The following APIs can be combined with toDate.
Schemas
any, custom, number, string, unknown
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/toDate/