Skip to content

Schema.dateISO

Description

Validates a ISO 8601 date string. By default using the YYYY-MM-DD format.

Format variables

VariableValueDescription
YYYY0000 - 9999Full-Year
MM01 - 12Month
Www01 - 53Week of the Year
D1 - 7Day of the Week. 1 is Monday, 7 is Sunday
DD01 - 31Day of the Month. Validates not if the month has 31 or 30 or 28 days
DDD001 - 366Day of the Year. Validates not if the year is a leap year
-Allowed separator between two variable

Usage

ts
import * as Schema from "@bytelab.studio/schemify";

const schema = Schema.dateISO();

schema.validate("2025-9-16");
ts
import * as Schema from "@bytelab.studio/schemify";

const schema = Schema.dateISO({
    format: "YYYYMMDD"
});

schema.validate("2025916");

Options

OptionsTypeDefaultDescription
formatstring"YYYY-MM-DD"A ISO 8601 compatible date format

Definition

ts
export interface DateISOOptions extends PatternOptions {
    format?: string;
}

Hierarchy