Spec-Zone.ru › Valibot

toDate

Creates a to date transformation action.

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

Generics

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

Parameters

  • message TMessage

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

  • Action ToDateAction<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

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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