Spec-Zone.ru › Valibot

isoDateTime

Creates an ISO date time validation action.

Format: yyyy-mm-ddThh:mm

The regex used cannot validate the maximum number of days based on year and month. For example, "2023-06-31T00:00" is valid although June has only 30 days.

The regex also allows a space as a separator between the date and time parts instead of the "T" character.

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

Generics

  • TInput extends string
  • TMessage extends ErrorMessage<IsoDateTimeIssue<TInput>> | undefined

Parameters

  • message TMessage

Explanation

With isoDateTime you can validate the formatting of a string. If the input is not an ISO date time, you can use message to customize the error message.

Returns

  • Action IsoDateTimeAction<TInput, TMessage>

Examples

The following examples show how isoDateTime can be used.

ISO date time schema

Schema to validate an ISO date time.

const IsoDateTimeSchema = v.pipe(
  v.string(),
  v.isoDateTime('The date is badly formatted.')
);

Related

The following APIs can be combined with isoDateTime.

Schemas

any, custom, string

Methods

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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