Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions tests/draft2019-09/optional/format/duration.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"description": "validation of duration strings",
"comment": "RFC 3339 Appendix A defines the ABNF grammar for ISO-8601 durations used by JSON Schema format 'duration'. These tests enforce only the syntax defined by that grammar.",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"format": "duration"
Expand Down Expand Up @@ -135,6 +136,57 @@
"description": "element without unit",
"data": "P1",
"valid": false
},
{
"description": "all date and time components",
"data": "P1Y2M3DT4H5M6S",
"valid": true
},
{
"description": "date components only",
"data": "P1Y2M3D",
"valid": true
},
{
"description": "time components only",
"data": "PT1H2M3S",
"valid": true
},
{
"description": "month and day",
"data": "P1M2D",
"valid": true
},
{
"description": "hour and minute",
"data": "PT1H30M",
"valid": true
},
{
"description": "multi-digit values in all components",
"data": "P10Y10M10DT10H10M10S",
"valid": true
},
{
"description": "fractional duration is not allowed by RFC 3339 ABNF",
"comment": "numeric components use 1*DIGIT where DIGIT = %x30-39; '.' is not allowed",
"data": "PT0.5S",
"valid": false
},
{
"description": "leading whitespace is invalid",
"data": " P1D",
"valid": false
},
{
"description": "trailing whitespace is invalid",
"data": "P1D ",
"valid": false
},
{
"description": "empty string is invalid",
"data": "",
"valid": false
}
]
}
Expand Down
52 changes: 52 additions & 0 deletions tests/draft2020-12/optional/format/duration.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"description": "validation of duration strings",
"comment": "RFC 3339 Appendix A defines the ABNF grammar for ISO-8601 durations used by JSON Schema format 'duration'. These tests enforce only the syntax defined by that grammar.",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"format": "duration"
Expand Down Expand Up @@ -135,6 +136,57 @@
"description": "element without unit",
"data": "P1",
"valid": false
},
{
"description": "all date and time components",
"data": "P1Y2M3DT4H5M6S",
"valid": true
},
{
"description": "date components only",
"data": "P1Y2M3D",
"valid": true
},
{
"description": "time components only",
"data": "PT1H2M3S",
"valid": true
},
{
"description": "month and day",
"data": "P1M2D",
"valid": true
},
{
"description": "hour and minute",
"data": "PT1H30M",
"valid": true
},
{
"description": "multi-digit values in all components",
"data": "P10Y10M10DT10H10M10S",
"valid": true
},
{
"description": "fractional duration is not allowed by RFC 3339 ABNF",
"comment": "numeric components use 1*DIGIT where DIGIT = %x30-39; '.' is not allowed",
"data": "PT0.5S",
"valid": false
},
{
"description": "leading whitespace is invalid",
"data": " P1D",
"valid": false
},
{
"description": "trailing whitespace is invalid",
"data": "P1D ",
"valid": false
},
{
"description": "empty string is invalid",
"data": "",
"valid": false
}
]
}
Expand Down
52 changes: 52 additions & 0 deletions tests/v1/format/duration.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{
"description": "validation of duration strings",
"comment": "RFC 3339 Appendix A defines the ABNF grammar for ISO-8601 durations used by JSON Schema format 'duration'. These tests enforce only the syntax defined by that grammar.",
"schema": {
"$schema": "https://json-schema.org/v1",
"format": "duration"
Expand Down Expand Up @@ -135,6 +136,57 @@
"description": "element without unit",
"data": "P1",
"valid": false
},
{
"description": "all date and time components",
"data": "P1Y2M3DT4H5M6S",
"valid": true
},
{
"description": "date components only",
"data": "P1Y2M3D",
"valid": true
},
{
"description": "time components only",
"data": "PT1H2M3S",
"valid": true
},
{
"description": "month and day",
"data": "P1M2D",
"valid": true
},
{
"description": "hour and minute",
"data": "PT1H30M",
"valid": true
},
{
"description": "multi-digit values in all components",
"data": "P10Y10M10DT10H10M10S",
"valid": true
},
{
"description": "fractional duration is not allowed by RFC 3339 ABNF",
"comment": "numeric components use 1*DIGIT where DIGIT = %x30-39; '.' is not allowed",
"data": "PT0.5S",
"valid": false
},
{
"description": "leading whitespace is invalid",
"data": " P1D",
"valid": false
},
{
"description": "trailing whitespace is invalid",
"data": "P1D ",
"valid": false
},
{
"description": "empty string is invalid",
"data": "",
"valid": false
}
]
}
Expand Down
Loading