Spec-Zone.ru › Valibot

isoDate

Creates an ISO date validation action.

Format: yyyy-mm-dd

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

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

Generics

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

Parameters

  • message TMessage

Explanation

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

Returns

  • Action IsoDateAction<TInput, TMessage>

Examples

The following examples show how isoDate can be used.

ISO date schema

Schema to validate an ISO date.

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

Minimum value schema

Schema to validate an ISO date is after a certain date.

const MinValueSchema = v.pipe(
  v.string(),
  v.isoDate(),
  v.minValue('2000-01-01', 'The date must be after the year 1999.')
);

Related

The following APIs can be combined with isoDate.

Schemas

any, custom, string

Methods

pipe

Utils

isOfKind, isOfType

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

Spec-Zone.ru

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