diff --git a/README.markdown b/README.markdown index 6bf97634..0a94ba26 100644 --- a/README.markdown +++ b/README.markdown @@ -48,6 +48,7 @@ expressed as JSON Schema definitions. | IETF | [RFC 8141](https://www.rfc-editor.org/rfc/rfc8141) | Uniform Resource Names (URNs) | | IETF | [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110) | HTTP Semantics | | ISO | [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) | Codes for the representation of currencies and funds | +| ISO | [ISO 8601-1:2019](https://www.iso.org/standard/70907.html) | Date and time — Representations for information interchange — Part 1: Basic rules | | ISO | [ISO 80000-1:2022](https://www.iso.org/standard/76921.html) | Quantities and units — Part 1: General | | ISO/IEC | [ISO/IEC 2382:2015](https://www.iso.org/standard/63598.html) | Information technology — Vocabulary | | JSON-RPC | [JSON-RPC 2.0](https://www.jsonrpc.org/specification) | JSON-RPC 2.0 Specification | diff --git a/schemas/iso/datetime/2019/duration-calendar-basic.json b/schemas/iso/datetime/2019/duration-calendar-basic.json new file mode 100644 index 00000000..bd61d222 --- /dev/null +++ b/schemas/iso/datetime/2019/duration-calendar-basic.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "ISO 8601-1:2019 Duration (Alternative Calendar Basic Format)", + "description": "A duration in alternative basic format P[YYYYMMDD]T[HHMMSS] (§5.5.2.4)", + "$comment": "https://www.iso.org/standard/70907.html", + "examples": [ "P00020110T223355", "P00010101T000000", "P00001231T235959" ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "type": "string", + "pattern": "^P(?:[0-9]{4}|[+-][0-9]{5,})(?:0[1-9]|1[0-2])(?:0[1-9]|[12][0-9]|3[01])T(?:[01][0-9]|2[0-3])(?:[0-5][0-9])(?:[0-5][0-9])$" +} diff --git a/schemas/iso/datetime/2019/duration-calendar-extended.json b/schemas/iso/datetime/2019/duration-calendar-extended.json new file mode 100644 index 00000000..3faa52c1 --- /dev/null +++ b/schemas/iso/datetime/2019/duration-calendar-extended.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "ISO 8601-1:2019 Duration (Alternative Calendar Extended Format)", + "description": "A duration in alternative extended format P[YYYY-MM-DD]T[HH:MM:SS] (§5.5.2.4)", + "$comment": "https://www.iso.org/standard/70907.html", + "examples": [ + "P0002-01-10T22:33:55", + "P0001-01-01T00:00:00", + "P0001-12-31T23:59:59" + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "type": "string", + "pattern": "^P(?:[0-9]{4}|[+-][0-9]{5,})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])T(?:[01][0-9]|2[0-3]):(?:[0-5][0-9]):(?:[0-5][0-9])$" +} diff --git a/schemas/iso/datetime/2019/duration-designator.json b/schemas/iso/datetime/2019/duration-designator.json new file mode 100644 index 00000000..e09fe71a --- /dev/null +++ b/schemas/iso/datetime/2019/duration-designator.json @@ -0,0 +1,223 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "ISO 8601-1:2019 Duration (Designator Format)", + "description": "A duration in designator format P[n]Y[n]M[n]DT[n]H[n]M[n]S (§5.5.2.2, §5.5.2.3)", + "$comment": "https://www.iso.org/standard/70907.html", + "examples": [ + "P3Y6M4DT12H30M5S", + "P1Y", + "PT1H", + "P1DT1S", + "P0Y0M0DT0H0M0S", + "P1.5Y", + "PT0.5H" + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "type": "string", + "allOf": [ + { + "not": { + "const": "P" + } + }, + { + "not": { + "const": "PT" + } + } + ], + "anyOf": [ + { + "$comment": "Date-only: Years with decimal (lowest order)", + "pattern": "^P[0-9]+(?:\\.[0-9]+)?Y$" + }, + { + "$comment": "Date-only: Years (integer) + Months with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date-only: Years (integer) + Months (integer) + Days with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+(?:\\.[0-9]+)?D$" + }, + { + "$comment": "Date-only: Months with decimal (lowest order)", + "pattern": "^P[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date-only: Months (integer) + Days with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+(?:\\.[0-9]+)?D$" + }, + { + "$comment": "Date-only: Days with decimal (lowest order)", + "pattern": "^P[0-9]+(?:\\.[0-9]+)?D$" + }, + { + "$comment": "Time-only: Hours with decimal (lowest order)", + "pattern": "^PT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Time-only: Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^PT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Time-only: Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^PT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Time-only: Minutes with decimal (lowest order)", + "pattern": "^PT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Time-only: Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^PT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Time-only: Seconds with decimal (lowest order)", + "pattern": "^PT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Years + Hours with decimal (lowest order)", + "pattern": "^P[0-9]+YT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Date+Time: Years + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+YT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date+Time: Years + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+YT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Years + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+YT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date+Time: Years + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+YT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Years + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+YT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Years (integer) + Months + Hours with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+MT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Date+Time: Years (integer) + Months + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+MT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date+Time: Years (integer) + Months + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+MT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Years (integer) + Months + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+MT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date+Time: Years (integer) + Months + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+MT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Years (integer) + Months + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+MT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Years (integer) + Months (integer) + Days + Hours with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Date+Time: Years (integer) + Months (integer) + Days + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date+Time: Years (integer) + Months (integer) + Days + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Years (integer) + Months (integer) + Days + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date+Time: Years (integer) + Months (integer) + Days + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Years (integer) + Months (integer) + Days + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Months + Hours with decimal (lowest order)", + "pattern": "^P[0-9]+MT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Date+Time: Months + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+MT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date+Time: Months + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+MT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Months + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+MT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date+Time: Months + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+MT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Months + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+MT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Months (integer) + Days + Hours with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Date+Time: Months (integer) + Days + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+DT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date+Time: Months (integer) + Days + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+DT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Months (integer) + Days + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date+Time: Months (integer) + Days + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+DT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Months (integer) + Days + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Days + Hours with decimal (lowest order)", + "pattern": "^P[0-9]+DT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Date+Time: Days + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+DT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date+Time: Days + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+DT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Days + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+DT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Date+Time: Days + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+DT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Date+Time: Days + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+DT[0-9]+(?:\\.[0-9]+)?S$" + } + ] +} diff --git a/schemas/iso/datetime/2019/duration-ordinal-basic.json b/schemas/iso/datetime/2019/duration-ordinal-basic.json new file mode 100644 index 00000000..8695dc0c --- /dev/null +++ b/schemas/iso/datetime/2019/duration-ordinal-basic.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "ISO 8601-1:2019 Duration (Alternative Ordinal Basic Format)", + "description": "A duration in alternative basic format with ordinal date P[YYYYDDD]T[HHMMSS] (§5.5.2.4)", + "$comment": "https://www.iso.org/standard/70907.html", + "examples": [ "P0002178T223355", "P0001001T000000", "P0001365T235959" ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "type": "string", + "pattern": "^P(?:[0-9]{4}|[+-][0-9]{5,})(?:0[0-9][1-9]|0[1-9][0-9]|[12][0-9]{2}|3[0-5][0-9]|36[0-6])T(?:[01][0-9]|2[0-3])(?:[0-5][0-9])(?:[0-5][0-9])$" +} diff --git a/schemas/iso/datetime/2019/duration-ordinal-extended.json b/schemas/iso/datetime/2019/duration-ordinal-extended.json new file mode 100644 index 00000000..350491d6 --- /dev/null +++ b/schemas/iso/datetime/2019/duration-ordinal-extended.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "ISO 8601-1:2019 Duration (Alternative Ordinal Extended Format)", + "description": "A duration in alternative extended format with ordinal date P[YYYY-DDD]T[HH:MM:SS] (§5.5.2.4)", + "$comment": "https://www.iso.org/standard/70907.html", + "examples": [ + "P0002-178T22:33:55", + "P0001-001T00:00:00", + "P0001-365T23:59:59" + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "type": "string", + "pattern": "^P(?:[0-9]{4}|[+-][0-9]{5,})-(?:0[0-9][1-9]|0[1-9][0-9]|[12][0-9]{2}|3[0-5][0-9]|36[0-6])T(?:[01][0-9]|2[0-3]):(?:[0-5][0-9]):(?:[0-5][0-9])$" +} diff --git a/schemas/iso/datetime/2019/duration-weeks.json b/schemas/iso/datetime/2019/duration-weeks.json new file mode 100644 index 00000000..be2d0c89 --- /dev/null +++ b/schemas/iso/datetime/2019/duration-weeks.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "ISO 8601-1:2019 Duration (Weeks Format)", + "description": "A duration in complete representation with weeks format P[n]W (§5.5.2.2)", + "$comment": "https://www.iso.org/standard/70907.html", + "examples": [ "P10W", "P1W", "P52W", "P0W", "P1.5W" ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "type": "string", + "pattern": "^P[0-9]+(?:\\.[0-9]+)?W$" +} diff --git a/test/iso/datetime/2019/duration-calendar-basic.test.json b/test/iso/datetime/2019/duration-calendar-basic.test.json new file mode 100644 index 00000000..0bb71e1a --- /dev/null +++ b/test/iso/datetime/2019/duration-calendar-basic.test.json @@ -0,0 +1,286 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../../schemas/iso/datetime/2019/duration-calendar-basic.json", + "tests": [ + { + "description": "Invalid type - integer", + "data": 20110223, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + }, + { + "description": "Valid - 2 years 1 month 10 days, 22 hours 33 minutes 55 seconds", + "data": "P00020110T223355", + "valid": true + }, + { + "description": "Valid - 1 year 1 month 1 day, 0 hours 0 minutes 0 seconds", + "data": "P00010101T000000", + "valid": true + }, + { + "description": "Valid - 0 years 12 months 31 days, 23 hours 59 minutes 59 seconds", + "data": "P00001231T235959", + "valid": true + }, + { + "description": "Valid - 10 years 6 months 15 days, 12 hours 30 minutes 45 seconds", + "data": "P00100615T123045", + "valid": true + }, + { + "description": "Invalid - missing P prefix", + "data": "00020110T223355", + "valid": false + }, + { + "description": "Invalid - missing T separator", + "data": "P00020110223355", + "valid": false + }, + { + "description": "Invalid - lowercase p", + "data": "p00020110T223355", + "valid": false + }, + { + "description": "Invalid - lowercase t", + "data": "P00020110t223355", + "valid": false + }, + { + "description": "Invalid - too few date digits", + "data": "P0020110T223355", + "valid": false + }, + { + "description": "Invalid - too many date digits", + "data": "P000020110T223355", + "valid": false + }, + { + "description": "Invalid - too few time digits", + "data": "P00020110T22335", + "valid": false + }, + { + "description": "Invalid - too many time digits", + "data": "P00020110T2233555", + "valid": false + }, + { + "description": "Invalid - empty string", + "data": "", + "valid": false + }, + { + "description": "Invalid - spaces in duration", + "data": "P0002 0110 T22 33 55", + "valid": false + }, + { + "description": "Invalid - hyphens (extended format)", + "data": "P0002-01-10T22:33:55", + "valid": false + }, + { + "description": "Invalid - colons in time (extended format)", + "data": "P00020110T22:33:55", + "valid": false + }, + { + "description": "Invalid - month 00 (months should be 01-12)", + "data": "P00000001T000000", + "valid": false + }, + { + "description": "Invalid - month 00 with valid day (months should be 01-12)", + "data": "P00010001T000000", + "valid": false + }, + { + "description": "Invalid - month 13 (months should be 01-12)", + "data": "P00011301T000000", + "valid": false + }, + { + "description": "Invalid - month 99 (months should be 01-12)", + "data": "P00019901T000000", + "valid": false + }, + { + "description": "Invalid - day 00 (days should be 01-31)", + "data": "P00010100T000000", + "valid": false + }, + { + "description": "Invalid - day 32 (days should be 01-31)", + "data": "P00010132T000000", + "valid": false + }, + { + "description": "Invalid - day 99 (days should be 01-31)", + "data": "P00010199T000000", + "valid": false + }, + { + "description": "Invalid - hour 24 (hours should be 00-23)", + "data": "P00010101T240000", + "valid": false + }, + { + "description": "Invalid - hour 99 (hours should be 00-23)", + "data": "P00010101T990000", + "valid": false + }, + { + "description": "Invalid - minute 60 (minutes should be 00-59)", + "data": "P00010101T006000", + "valid": false + }, + { + "description": "Invalid - minute 99 (minutes should be 00-59)", + "data": "P00010101T009900", + "valid": false + }, + { + "description": "Invalid - second 60 (seconds should be 00-59)", + "data": "P00010101T000060", + "valid": false + }, + { + "description": "Invalid - second 99 (seconds should be 00-59)", + "data": "P00010101T000099", + "valid": false + }, + { + "description": "Valid - month 01 (minimum valid month)", + "data": "P00000101T000000", + "valid": true + }, + { + "description": "Valid - month 12 (maximum valid month)", + "data": "P00001201T000000", + "valid": true + }, + { + "description": "Valid - day 01 (minimum valid day)", + "data": "P00000101T000000", + "valid": true + }, + { + "description": "Valid - day 31 (maximum valid day)", + "data": "P00000131T000000", + "valid": true + }, + { + "description": "Valid - hour 00 (minimum valid hour)", + "data": "P00000101T000000", + "valid": true + }, + { + "description": "Valid - hour 23 (maximum valid hour)", + "data": "P00000101T230000", + "valid": true + }, + { + "description": "Valid - minute 00 (minimum valid minute)", + "data": "P00000101T000000", + "valid": true + }, + { + "description": "Valid - minute 59 (maximum valid minute)", + "data": "P00000101T005900", + "valid": true + }, + { + "description": "Valid - second 00 (minimum valid second)", + "data": "P00000101T000000", + "valid": true + }, + { + "description": "Valid - second 59 (maximum valid second)", + "data": "P00000101T000059", + "valid": true + }, + { + "description": "Valid - expanded year with plus sign (5 digits)", + "data": "P+100000101T000000", + "valid": true + }, + { + "description": "Valid - expanded year with minus sign (5 digits)", + "data": "P-100000101T000000", + "valid": true + }, + { + "description": "Valid - expanded year with plus sign (6 digits)", + "data": "P+10000000101T000000", + "valid": true + }, + { + "description": "Valid - expanded year with minus sign (10 digits)", + "data": "P-10000000000101T000000", + "valid": true + }, + { + "description": "Invalid - expanded year without sign (5 digits)", + "data": "P100000101T000000", + "valid": false + }, + { + "description": "Invalid - 4 digit year with plus sign", + "data": "P+00010101T000000", + "valid": false + }, + { + "description": "Invalid - 4 digit year with minus sign", + "data": "P-00010101T000000", + "valid": false + }, + { + "description": "Invalid - month without leading zero (single digit)", + "data": "P00000101T00000", + "valid": false + }, + { + "description": "Invalid - day without leading zero (single digit)", + "data": "P0000011T00000", + "valid": false + }, + { + "description": "Invalid - hour without leading zero (single digit)", + "data": "P00000101T10000", + "valid": false + }, + { + "description": "Invalid - minute without leading zero (single digit)", + "data": "P00000101T00100", + "valid": false + }, + { + "description": "Invalid - second without leading zero (single digit)", + "data": "P00000101T00001", + "valid": false + } + ] +} diff --git a/test/iso/datetime/2019/duration-calendar-extended.test.json b/test/iso/datetime/2019/duration-calendar-extended.test.json new file mode 100644 index 00000000..ea5ecfc0 --- /dev/null +++ b/test/iso/datetime/2019/duration-calendar-extended.test.json @@ -0,0 +1,286 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../../schemas/iso/datetime/2019/duration-calendar-extended.json", + "tests": [ + { + "description": "Invalid type - integer", + "data": 20110223, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + }, + { + "description": "Valid - 2 years 1 month 10 days, 22 hours 33 minutes 55 seconds", + "data": "P0002-01-10T22:33:55", + "valid": true + }, + { + "description": "Valid - 1 year 1 month 1 day, 0 hours 0 minutes 0 seconds", + "data": "P0001-01-01T00:00:00", + "valid": true + }, + { + "description": "Valid - 0 years 12 months 31 days, 23 hours 59 minutes 59 seconds", + "data": "P0000-12-31T23:59:59", + "valid": true + }, + { + "description": "Valid - 10 years 6 months 15 days, 12 hours 30 minutes 45 seconds", + "data": "P0010-06-15T12:30:45", + "valid": true + }, + { + "description": "Invalid - missing P prefix", + "data": "0002-01-10T22:33:55", + "valid": false + }, + { + "description": "Invalid - missing T separator", + "data": "P0002-01-1022:33:55", + "valid": false + }, + { + "description": "Invalid - lowercase p", + "data": "p0002-01-10T22:33:55", + "valid": false + }, + { + "description": "Invalid - lowercase t", + "data": "P0002-01-10t22:33:55", + "valid": false + }, + { + "description": "Invalid - missing date hyphens", + "data": "P00020110T22:33:55", + "valid": false + }, + { + "description": "Invalid - missing time colons", + "data": "P0002-01-10T223355", + "valid": false + }, + { + "description": "Invalid - too few year digits", + "data": "P002-01-10T22:33:55", + "valid": false + }, + { + "description": "Invalid - too many year digits", + "data": "P00002-01-10T22:33:55", + "valid": false + }, + { + "description": "Invalid - too few month digits", + "data": "P0002-1-10T22:33:55", + "valid": false + }, + { + "description": "Invalid - too many month digits", + "data": "P0002-001-10T22:33:55", + "valid": false + }, + { + "description": "Invalid - empty string", + "data": "", + "valid": false + }, + { + "description": "Invalid - spaces in duration", + "data": "P0002-01-10 T 22:33:55", + "valid": false + }, + { + "description": "Invalid - month 00 (months should be 01-12)", + "data": "P0000-00-01T00:00:00", + "valid": false + }, + { + "description": "Invalid - month 00 with valid day (months should be 01-12)", + "data": "P0001-00-01T00:00:00", + "valid": false + }, + { + "description": "Invalid - month 13 (months should be 01-12)", + "data": "P0001-13-01T00:00:00", + "valid": false + }, + { + "description": "Invalid - month 99 (months should be 01-12)", + "data": "P0001-99-01T00:00:00", + "valid": false + }, + { + "description": "Invalid - day 00 (days should be 01-31)", + "data": "P0001-01-00T00:00:00", + "valid": false + }, + { + "description": "Invalid - day 32 (days should be 01-31)", + "data": "P0001-01-32T00:00:00", + "valid": false + }, + { + "description": "Invalid - day 99 (days should be 01-31)", + "data": "P0001-01-99T00:00:00", + "valid": false + }, + { + "description": "Invalid - hour 24 (hours should be 00-23)", + "data": "P0001-01-01T24:00:00", + "valid": false + }, + { + "description": "Invalid - hour 99 (hours should be 00-23)", + "data": "P0001-01-01T99:00:00", + "valid": false + }, + { + "description": "Invalid - minute 60 (minutes should be 00-59)", + "data": "P0001-01-01T00:60:00", + "valid": false + }, + { + "description": "Invalid - minute 99 (minutes should be 00-59)", + "data": "P0001-01-01T00:99:00", + "valid": false + }, + { + "description": "Invalid - second 60 (seconds should be 00-59)", + "data": "P0001-01-01T00:00:60", + "valid": false + }, + { + "description": "Invalid - second 99 (seconds should be 00-59)", + "data": "P0001-01-01T00:00:99", + "valid": false + }, + { + "description": "Valid - month 01 (minimum valid month)", + "data": "P0000-01-01T00:00:00", + "valid": true + }, + { + "description": "Valid - month 12 (maximum valid month)", + "data": "P0000-12-01T00:00:00", + "valid": true + }, + { + "description": "Valid - day 01 (minimum valid day)", + "data": "P0000-01-01T00:00:00", + "valid": true + }, + { + "description": "Valid - day 31 (maximum valid day)", + "data": "P0000-01-31T00:00:00", + "valid": true + }, + { + "description": "Valid - hour 00 (minimum valid hour)", + "data": "P0000-01-01T00:00:00", + "valid": true + }, + { + "description": "Valid - hour 23 (maximum valid hour)", + "data": "P0000-01-01T23:00:00", + "valid": true + }, + { + "description": "Valid - minute 00 (minimum valid minute)", + "data": "P0000-01-01T00:00:00", + "valid": true + }, + { + "description": "Valid - minute 59 (maximum valid minute)", + "data": "P0000-01-01T00:59:00", + "valid": true + }, + { + "description": "Valid - second 00 (minimum valid second)", + "data": "P0000-01-01T00:00:00", + "valid": true + }, + { + "description": "Valid - second 59 (maximum valid second)", + "data": "P0000-01-01T00:00:59", + "valid": true + }, + { + "description": "Valid - expanded year with plus sign (5 digits)", + "data": "P+10000-01-01T00:00:00", + "valid": true + }, + { + "description": "Valid - expanded year with minus sign (5 digits)", + "data": "P-10000-01-01T00:00:00", + "valid": true + }, + { + "description": "Valid - expanded year with plus sign (6 digits)", + "data": "P+100000-01-01T00:00:00", + "valid": true + }, + { + "description": "Valid - expanded year with minus sign (10 digits)", + "data": "P-1000000000-01-01T00:00:00", + "valid": true + }, + { + "description": "Invalid - expanded year without sign (5 digits)", + "data": "P10000-01-01T00:00:00", + "valid": false + }, + { + "description": "Invalid - 4 digit year with plus sign", + "data": "P+0001-01-01T00:00:00", + "valid": false + }, + { + "description": "Invalid - 4 digit year with minus sign", + "data": "P-0001-01-01T00:00:00", + "valid": false + }, + { + "description": "Invalid - month without leading zero (single digit)", + "data": "P0000-1-01T00:00:00", + "valid": false + }, + { + "description": "Invalid - day without leading zero (single digit)", + "data": "P0000-01-1T00:00:00", + "valid": false + }, + { + "description": "Invalid - hour without leading zero (single digit)", + "data": "P0000-01-01T1:00:00", + "valid": false + }, + { + "description": "Invalid - minute without leading zero (single digit)", + "data": "P0000-01-01T00:1:00", + "valid": false + }, + { + "description": "Invalid - second without leading zero (single digit)", + "data": "P0000-01-01T00:00:1", + "valid": false + } + ] +} diff --git a/test/iso/datetime/2019/duration-designator.test.json b/test/iso/datetime/2019/duration-designator.test.json new file mode 100644 index 00000000..9de07efe --- /dev/null +++ b/test/iso/datetime/2019/duration-designator.test.json @@ -0,0 +1,201 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../../schemas/iso/datetime/2019/duration-designator.json", + "tests": [ + { + "description": "Invalid type - integer", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + }, + { + "description": "Valid - full duration with all components", + "data": "P3Y6M4DT12H30M5S", + "valid": true + }, + { + "description": "Valid - only years", + "data": "P1Y", + "valid": true + }, + { + "description": "Valid - only time component (hours)", + "data": "PT1H", + "valid": true + }, + { + "description": "Valid - days and seconds", + "data": "P1DT1S", + "valid": true + }, + { + "description": "Valid - all zeros", + "data": "P0Y0M0DT0H0M0S", + "valid": true + }, + { + "description": "Valid - only months", + "data": "P5M", + "valid": true + }, + { + "description": "Valid - only days", + "data": "P100D", + "valid": true + }, + { + "description": "Valid - only minutes", + "data": "PT30M", + "valid": true + }, + { + "description": "Valid - only seconds", + "data": "PT45S", + "valid": true + }, + { + "description": "Valid - seconds with decimal fraction", + "data": "PT1.5S", + "valid": true + }, + { + "description": "Valid - years and months", + "data": "P2Y3M", + "valid": true + }, + { + "description": "Valid - hours and minutes", + "data": "PT12H30M", + "valid": true + }, + { + "description": "Invalid - missing P prefix", + "data": "3Y6M4DT12H30M5S", + "valid": false + }, + { + "description": "Invalid - lowercase p", + "data": "p1Y", + "valid": false + }, + { + "description": "Invalid - lowercase t", + "data": "P1Dt1H", + "valid": false + }, + { + "description": "Invalid - time component without T", + "data": "P1D1H", + "valid": false + }, + { + "description": "Invalid - empty string", + "data": "", + "valid": false + }, + { + "description": "Invalid - only P", + "data": "P", + "valid": false + }, + { + "description": "Invalid - only PT", + "data": "PT", + "valid": false + }, + { + "description": "Invalid - spaces in duration", + "data": "P1Y 2M", + "valid": false + }, + { + "description": "Invalid - wrong order (months before years)", + "data": "P6M3Y", + "valid": false + }, + { + "description": "Valid - 13 months (durations can exceed calendar limits)", + "data": "P13M", + "valid": true + }, + { + "description": "Valid - 32 days (durations can exceed calendar limits)", + "data": "P32D", + "valid": true + }, + { + "description": "Valid - 25 hours (durations can exceed calendar limits)", + "data": "PT25H", + "valid": true + }, + { + "description": "Valid - 60 minutes (durations can exceed calendar limits)", + "data": "PT60M", + "valid": true + }, + { + "description": "Valid - 60 seconds (durations can exceed calendar limits)", + "data": "PT60S", + "valid": true + }, + { + "description": "Valid - 100 hours (durations can exceed calendar limits)", + "data": "PT100H", + "valid": true + }, + { + "description": "Valid - 500 days (durations can exceed calendar limits)", + "data": "P500D", + "valid": true + }, + { + "description": "Valid - zero years", + "data": "P0Y", + "valid": true + }, + { + "description": "Valid - zero months", + "data": "P0M", + "valid": true + }, + { + "description": "Valid - zero days", + "data": "P0D", + "valid": true + }, + { + "description": "Valid - zero hours", + "data": "PT0H", + "valid": true + }, + { + "description": "Valid - zero minutes", + "data": "PT0M", + "valid": true + }, + { + "description": "Valid - zero seconds", + "data": "PT0S", + "valid": true + } + ] +} diff --git a/test/iso/datetime/2019/duration-ordinal-basic.test.json b/test/iso/datetime/2019/duration-ordinal-basic.test.json new file mode 100644 index 00000000..cf38ef9f --- /dev/null +++ b/test/iso/datetime/2019/duration-ordinal-basic.test.json @@ -0,0 +1,266 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../../schemas/iso/datetime/2019/duration-ordinal-basic.json", + "tests": [ + { + "description": "Invalid type - integer", + "data": 2178223355, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + }, + { + "description": "Valid - 2 years day 178, 22 hours 33 minutes 55 seconds", + "data": "P0002178T223355", + "valid": true + }, + { + "description": "Valid - 1 year day 1, 0 hours 0 minutes 0 seconds", + "data": "P0001001T000000", + "valid": true + }, + { + "description": "Valid - 1 year day 365, 23 hours 59 minutes 59 seconds", + "data": "P0001365T235959", + "valid": true + }, + { + "description": "Valid - 10 years day 100, 12 hours 30 minutes 45 seconds", + "data": "P0010100T123045", + "valid": true + }, + { + "description": "Valid - 5 years day 366 (leap year), 6 hours 15 minutes 30 seconds", + "data": "P0005366T061530", + "valid": true + }, + { + "description": "Invalid - missing P prefix", + "data": "0002178T223355", + "valid": false + }, + { + "description": "Invalid - missing T separator", + "data": "P0002178223355", + "valid": false + }, + { + "description": "Invalid - lowercase p", + "data": "p0002178T223355", + "valid": false + }, + { + "description": "Invalid - lowercase t", + "data": "P0002178t223355", + "valid": false + }, + { + "description": "Invalid - too few ordinal date digits", + "data": "P000278T223355", + "valid": false + }, + { + "description": "Invalid - too many ordinal date digits", + "data": "P00002178T223355", + "valid": false + }, + { + "description": "Invalid - too few time digits", + "data": "P0002178T22335", + "valid": false + }, + { + "description": "Invalid - too many time digits", + "data": "P0002178T2233555", + "valid": false + }, + { + "description": "Invalid - empty string", + "data": "", + "valid": false + }, + { + "description": "Invalid - spaces in duration", + "data": "P0002 178 T22 33 55", + "valid": false + }, + { + "description": "Invalid - hyphen (extended format)", + "data": "P0002-178T223355", + "valid": false + }, + { + "description": "Invalid - colons in time (extended format)", + "data": "P0002178T22:33:55", + "valid": false + }, + { + "description": "Invalid - ordinal day 000 (ordinal days should be 001-366)", + "data": "P0001000T000000", + "valid": false + }, + { + "description": "Invalid - ordinal day 367 (ordinal days should be 001-366)", + "data": "P0001367T000000", + "valid": false + }, + { + "description": "Invalid - ordinal day 999 (ordinal days should be 001-366)", + "data": "P0001999T000000", + "valid": false + }, + { + "description": "Invalid - hour 24 (hours should be 00-23)", + "data": "P0001001T240000", + "valid": false + }, + { + "description": "Invalid - hour 99 (hours should be 00-23)", + "data": "P0001001T990000", + "valid": false + }, + { + "description": "Invalid - minute 60 (minutes should be 00-59)", + "data": "P0001001T006000", + "valid": false + }, + { + "description": "Invalid - minute 99 (minutes should be 00-59)", + "data": "P0001001T009900", + "valid": false + }, + { + "description": "Invalid - second 60 (seconds should be 00-59)", + "data": "P0001001T000060", + "valid": false + }, + { + "description": "Invalid - second 99 (seconds should be 00-59)", + "data": "P0001001T000099", + "valid": false + }, + { + "description": "Valid - ordinal day 001 (minimum valid ordinal day)", + "data": "P0000001T000000", + "valid": true + }, + { + "description": "Valid - ordinal day 366 (maximum valid ordinal day)", + "data": "P0000366T000000", + "valid": true + }, + { + "description": "Valid - ordinal day 365", + "data": "P0000365T000000", + "valid": true + }, + { + "description": "Valid - hour 00 (minimum valid hour)", + "data": "P0000001T000000", + "valid": true + }, + { + "description": "Valid - hour 23 (maximum valid hour)", + "data": "P0000001T230000", + "valid": true + }, + { + "description": "Valid - minute 00 (minimum valid minute)", + "data": "P0000001T000000", + "valid": true + }, + { + "description": "Valid - minute 59 (maximum valid minute)", + "data": "P0000001T005900", + "valid": true + }, + { + "description": "Valid - second 00 (minimum valid second)", + "data": "P0000001T000000", + "valid": true + }, + { + "description": "Valid - second 59 (maximum valid second)", + "data": "P0000001T000059", + "valid": true + }, + { + "description": "Valid - expanded year with plus sign (5 digits)", + "data": "P+10000001T000000", + "valid": true + }, + { + "description": "Valid - expanded year with minus sign (5 digits)", + "data": "P-10000001T000000", + "valid": true + }, + { + "description": "Valid - expanded year with plus sign (6 digits)", + "data": "P+100000001T000000", + "valid": true + }, + { + "description": "Valid - expanded year with minus sign (10 digits)", + "data": "P-1000000000001T000000", + "valid": true + }, + { + "description": "Invalid - expanded year without sign (5 digits)", + "data": "P10000001T000000", + "valid": false + }, + { + "description": "Invalid - 4 digit year with plus sign", + "data": "P+0001001T000000", + "valid": false + }, + { + "description": "Invalid - 4 digit year with minus sign", + "data": "P-0001001T000000", + "valid": false + }, + { + "description": "Invalid - ordinal day without leading zeros (single digit)", + "data": "P00001T00000", + "valid": false + }, + { + "description": "Invalid - ordinal day without leading zeros (two digits)", + "data": "P000001T00000", + "valid": false + }, + { + "description": "Invalid - hour without leading zero (single digit)", + "data": "P0000001T10000", + "valid": false + }, + { + "description": "Invalid - minute without leading zero (single digit)", + "data": "P0000001T00100", + "valid": false + }, + { + "description": "Invalid - second without leading zero (single digit)", + "data": "P0000001T00001", + "valid": false + } + ] +} diff --git a/test/iso/datetime/2019/duration-ordinal-extended.test.json b/test/iso/datetime/2019/duration-ordinal-extended.test.json new file mode 100644 index 00000000..726712bf --- /dev/null +++ b/test/iso/datetime/2019/duration-ordinal-extended.test.json @@ -0,0 +1,266 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../../schemas/iso/datetime/2019/duration-ordinal-extended.json", + "tests": [ + { + "description": "Invalid type - integer", + "data": 2178223355, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + }, + { + "description": "Valid - 2 years day 178, 22 hours 33 minutes 55 seconds", + "data": "P0002-178T22:33:55", + "valid": true + }, + { + "description": "Valid - 1 year day 1, 0 hours 0 minutes 0 seconds", + "data": "P0001-001T00:00:00", + "valid": true + }, + { + "description": "Valid - 1 year day 365, 23 hours 59 minutes 59 seconds", + "data": "P0001-365T23:59:59", + "valid": true + }, + { + "description": "Valid - 10 years day 100, 12 hours 30 minutes 45 seconds", + "data": "P0010-100T12:30:45", + "valid": true + }, + { + "description": "Valid - 5 years day 366 (leap year), 6 hours 15 minutes 30 seconds", + "data": "P0005-366T06:15:30", + "valid": true + }, + { + "description": "Invalid - missing P prefix", + "data": "0002-178T22:33:55", + "valid": false + }, + { + "description": "Invalid - missing T separator", + "data": "P0002-17822:33:55", + "valid": false + }, + { + "description": "Invalid - lowercase p", + "data": "p0002-178T22:33:55", + "valid": false + }, + { + "description": "Invalid - lowercase t", + "data": "P0002-178t22:33:55", + "valid": false + }, + { + "description": "Invalid - missing hyphen", + "data": "P0002178T22:33:55", + "valid": false + }, + { + "description": "Invalid - missing time colons", + "data": "P0002-178T223355", + "valid": false + }, + { + "description": "Invalid - too few year digits", + "data": "P002-178T22:33:55", + "valid": false + }, + { + "description": "Invalid - too many year digits", + "data": "P00002-178T22:33:55", + "valid": false + }, + { + "description": "Invalid - too few day digits", + "data": "P0002-78T22:33:55", + "valid": false + }, + { + "description": "Invalid - too many day digits", + "data": "P0002-1780T22:33:55", + "valid": false + }, + { + "description": "Invalid - empty string", + "data": "", + "valid": false + }, + { + "description": "Invalid - spaces in duration", + "data": "P0002-178 T 22:33:55", + "valid": false + }, + { + "description": "Invalid - ordinal day 000 (ordinal days should be 001-366)", + "data": "P0001-000T00:00:00", + "valid": false + }, + { + "description": "Invalid - ordinal day 367 (ordinal days should be 001-366)", + "data": "P0001-367T00:00:00", + "valid": false + }, + { + "description": "Invalid - ordinal day 999 (ordinal days should be 001-366)", + "data": "P0001-999T00:00:00", + "valid": false + }, + { + "description": "Invalid - hour 24 (hours should be 00-23)", + "data": "P0001-001T24:00:00", + "valid": false + }, + { + "description": "Invalid - hour 99 (hours should be 00-23)", + "data": "P0001-001T99:00:00", + "valid": false + }, + { + "description": "Invalid - minute 60 (minutes should be 00-59)", + "data": "P0001-001T00:60:00", + "valid": false + }, + { + "description": "Invalid - minute 99 (minutes should be 00-59)", + "data": "P0001-001T00:99:00", + "valid": false + }, + { + "description": "Invalid - second 60 (seconds should be 00-59)", + "data": "P0001-001T00:00:60", + "valid": false + }, + { + "description": "Invalid - second 99 (seconds should be 00-59)", + "data": "P0001-001T00:00:99", + "valid": false + }, + { + "description": "Valid - ordinal day 001 (minimum valid ordinal day)", + "data": "P0000-001T00:00:00", + "valid": true + }, + { + "description": "Valid - ordinal day 366 (maximum valid ordinal day)", + "data": "P0000-366T00:00:00", + "valid": true + }, + { + "description": "Valid - ordinal day 365", + "data": "P0000-365T00:00:00", + "valid": true + }, + { + "description": "Valid - hour 00 (minimum valid hour)", + "data": "P0000-001T00:00:00", + "valid": true + }, + { + "description": "Valid - hour 23 (maximum valid hour)", + "data": "P0000-001T23:00:00", + "valid": true + }, + { + "description": "Valid - minute 00 (minimum valid minute)", + "data": "P0000-001T00:00:00", + "valid": true + }, + { + "description": "Valid - minute 59 (maximum valid minute)", + "data": "P0000-001T00:59:00", + "valid": true + }, + { + "description": "Valid - second 00 (minimum valid second)", + "data": "P0000-001T00:00:00", + "valid": true + }, + { + "description": "Valid - second 59 (maximum valid second)", + "data": "P0000-001T00:00:59", + "valid": true + }, + { + "description": "Valid - expanded year with plus sign (5 digits)", + "data": "P+10000-001T00:00:00", + "valid": true + }, + { + "description": "Valid - expanded year with minus sign (5 digits)", + "data": "P-10000-001T00:00:00", + "valid": true + }, + { + "description": "Valid - expanded year with plus sign (6 digits)", + "data": "P+100000-001T00:00:00", + "valid": true + }, + { + "description": "Valid - expanded year with minus sign (10 digits)", + "data": "P-1000000000-001T00:00:00", + "valid": true + }, + { + "description": "Invalid - expanded year without sign (5 digits)", + "data": "P10000-001T00:00:00", + "valid": false + }, + { + "description": "Invalid - 4 digit year with plus sign", + "data": "P+0001-001T00:00:00", + "valid": false + }, + { + "description": "Invalid - 4 digit year with minus sign", + "data": "P-0001-001T00:00:00", + "valid": false + }, + { + "description": "Invalid - ordinal day without leading zeros (single digit)", + "data": "P0000-1T00:00:00", + "valid": false + }, + { + "description": "Invalid - ordinal day without leading zeros (two digits)", + "data": "P0000-01T00:00:00", + "valid": false + }, + { + "description": "Invalid - hour without leading zero (single digit)", + "data": "P0000-001T1:00:00", + "valid": false + }, + { + "description": "Invalid - minute without leading zero (single digit)", + "data": "P0000-001T00:1:00", + "valid": false + }, + { + "description": "Invalid - second without leading zero (single digit)", + "data": "P0000-001T00:00:1", + "valid": false + } + ] +} diff --git a/test/iso/datetime/2019/duration-weeks.test.json b/test/iso/datetime/2019/duration-weeks.test.json new file mode 100644 index 00000000..2395e67c --- /dev/null +++ b/test/iso/datetime/2019/duration-weeks.test.json @@ -0,0 +1,116 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../../schemas/iso/datetime/2019/duration-weeks.json", + "tests": [ + { + "description": "Invalid type - integer", + "data": 10, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + }, + { + "description": "Valid - 10 weeks", + "data": "P10W", + "valid": true + }, + { + "description": "Valid - 1 week", + "data": "P1W", + "valid": true + }, + { + "description": "Valid - 52 weeks", + "data": "P52W", + "valid": true + }, + { + "description": "Valid - 0 weeks", + "data": "P0W", + "valid": true + }, + { + "description": "Valid - 100 weeks", + "data": "P100W", + "valid": true + }, + { + "description": "Invalid - missing P prefix", + "data": "10W", + "valid": false + }, + { + "description": "Invalid - lowercase p", + "data": "p10W", + "valid": false + }, + { + "description": "Invalid - lowercase w", + "data": "P10w", + "valid": false + }, + { + "description": "Invalid - empty string", + "data": "", + "valid": false + }, + { + "description": "Invalid - only P", + "data": "P", + "valid": false + }, + { + "description": "Invalid - only PW", + "data": "PW", + "valid": false + }, + { + "description": "Valid - decimal weeks", + "data": "P1.5W", + "valid": true + }, + { + "description": "Invalid - spaces in duration", + "data": "P 10 W", + "valid": false + }, + { + "description": "Invalid - additional characters", + "data": "P10WD", + "valid": false + }, + { + "description": "Invalid - weeks mixed with days (ISO 8601 discourages mixing)", + "data": "P1W2D", + "valid": false + }, + { + "description": "Invalid - weeks mixed with years", + "data": "P1Y2W", + "valid": false + }, + { + "description": "Invalid - weeks mixed with time", + "data": "P1WT1H", + "valid": false + } + ] +}