| 1 |
[ |
| 2 |
{ |
| 3 |
"description": "validation of duration strings", |
| 4 |
"schema": {"format": "duration"}, |
| 5 |
"comment": "see https://en.wikipedia.org/wiki/ISO_8601#Durations for examples and clarifications", |
| 6 |
"tests": [ |
| 7 |
{ |
| 8 |
"description": "years and months can appear without days", |
| 9 |
"data": "P1Y2M", |
| 10 |
"valid": true |
| 11 |
}, |
| 12 |
{ |
| 13 |
"description": "years and days cannot appear without months", |
| 14 |
"data": "P1Y2D", |
| 15 |
"valid": false |
| 16 |
}, |
| 17 |
{ |
| 18 |
"description": "months and days can appear without years", |
| 19 |
"data": "P1M2D", |
| 20 |
"valid": true |
| 21 |
}, |
| 22 |
{ |
| 23 |
"description": "hours and minutes can appear without seconds", |
| 24 |
"data": "PT1H2M", |
| 25 |
"valid": true |
| 26 |
}, |
| 27 |
{ |
| 28 |
"description": "hours and seconds cannot appear without minutes", |
| 29 |
"data": "PT1H2S", |
| 30 |
"valid": false |
| 31 |
}, |
| 32 |
{ |
| 33 |
"description": "minutes and seconds can appear without hour", |
| 34 |
"data": "PT1M2S", |
| 35 |
"valid": true |
| 36 |
}, |
| 37 |
{ |
| 38 |
"description": "half a year duration, with full stop decimal point", |
| 39 |
"comment": "ISO 8601 revision in year 2000 added decimals", |
| 40 |
"data": "P0.5Y", |
| 41 |
"valid": false |
| 42 |
}, |
| 43 |
{ |
| 44 |
"description": "half a year duration, with comma decimal point", |
| 45 |
"data": "P0,5Y", |
| 46 |
"valid": false |
| 47 |
}, |
| 48 |
{ |
| 49 |
"description": "only one (now zero) units can have a non-integer quantity", |
| 50 |
"data": "P0.5Y2.1M", |
| 51 |
"valid": false |
| 52 |
}, |
| 53 |
{ |
| 54 |
"description": "only the smallest unit can have a non-integer quantity", |
| 55 |
"data": "P0.5Y2M", |
| 56 |
"valid": false |
| 57 |
} |
| 58 |
] |
| 59 |
} |
| 60 |
] |