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
TInputextends stringTMessageextends ErrorMessage<IsoDateIssue<TInput>> | undefined
Parameters
messageTMessage
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
ActionIsoDateAction<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
Methods
Utils
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/isoDate/