Schema.dateISO
Description
Validates a ISO 8601 date string. By default using the YYYY-MM-DD format.
Format variables
| Variable | Value | Description |
|---|---|---|
YYYY | 0000 - 9999 | Full-Year |
MM | 01 - 12 | Month |
Www | 01 - 53 | Week of the Year |
D | 1 - 7 | Day of the Week. 1 is Monday, 7 is Sunday |
DD | 01 - 31 | Day of the Month. Validates not if the month has 31 or 30 or 28 days |
DDD | 001 - 366 | Day 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
| Options | Type | Default | Description |
|---|---|---|---|
format | string | "YYYY-MM-DD" | A ISO 8601 compatible date format |
Definition
ts
export interface DateISOOptions extends PatternOptions {
format?: string;
}