| 1 |
[ |
| 2 |
{ |
| 3 |
"description": "validation of duration strings", |
| 4 |
"schema": { |
| 5 |
"$schema": "https://json-schema.org/v1", |
| 6 |
"format": "duration" |
| 7 |
}, |
| 8 |
"tests": [ |
| 9 |
{ |
| 10 |
"description": "all string formats ignore integers", |
| 11 |
"data": 12, |
| 12 |
"valid": true |
| 13 |
}, |
| 14 |
{ |
| 15 |
"description": "all string formats ignore floats", |
| 16 |
"data": 13.7, |
| 17 |
"valid": true |
| 18 |
}, |
| 19 |
{ |
| 20 |
"description": "all string formats ignore objects", |
| 21 |
"data": {}, |
| 22 |
"valid": true |
| 23 |
}, |
| 24 |
{ |
| 25 |
"description": "all string formats ignore arrays", |
| 26 |
"data": [], |
| 27 |
"valid": true |
| 28 |
}, |
| 29 |
{ |
| 30 |
"description": "all string formats ignore booleans", |
| 31 |
"data": false, |
| 32 |
"valid": true |
| 33 |
}, |
| 34 |
{ |
| 35 |
"description": "all string formats ignore nulls", |
| 36 |
"data": null, |
| 37 |
"valid": true |
| 38 |
}, |
| 39 |
{ |
| 40 |
"description": "a valid duration string", |
| 41 |
"data": "P4DT12H30M5S", |
| 42 |
"valid": true |
| 43 |
}, |
| 44 |
{ |
| 45 |
"description": "an invalid duration string", |
| 46 |
"data": "PT1D", |
| 47 |
"valid": false |
| 48 |
}, |
| 49 |
{ |
| 50 |
"description": "must start with P", |
| 51 |
"data": "4DT12H30M5S", |
| 52 |
"valid": false |
| 53 |
}, |
| 54 |
{ |
| 55 |
"description": "no elements present", |
| 56 |
"data": "P", |
| 57 |
"valid": false |
| 58 |
}, |
| 59 |
{ |
| 60 |
"description": "no time elements present", |
| 61 |
"data": "P1YT", |
| 62 |
"valid": false |
| 63 |
}, |
| 64 |
{ |
| 65 |
"description": "no date or time elements present", |
| 66 |
"data": "PT", |
| 67 |
"valid": false |
| 68 |
}, |
| 69 |
{ |
| 70 |
"description": "elements out of order", |
| 71 |
"data": "P2D1Y", |
| 72 |
"valid": false |
| 73 |
}, |
| 74 |
{ |
| 75 |
"description": "missing time separator", |
| 76 |
"data": "P1D2H", |
| 77 |
"valid": false |
| 78 |
}, |
| 79 |
{ |
| 80 |
"description": "time element in the date position", |
| 81 |
"data": "P2S", |
| 82 |
"valid": false |
| 83 |
}, |
| 84 |
{ |
| 85 |
"description": "four years duration", |
| 86 |
"data": "P4Y", |
| 87 |
"valid": true |
| 88 |
}, |
| 89 |
{ |
| 90 |
"description": "zero time, in seconds", |
| 91 |
"data": "PT0S", |
| 92 |
"valid": true |
| 93 |
}, |
| 94 |
{ |
| 95 |
"description": "zero time, in days", |
| 96 |
"data": "P0D", |
| 97 |
"valid": true |
| 98 |
}, |
| 99 |
{ |
| 100 |
"description": "one month duration", |
| 101 |
"data": "P1M", |
| 102 |
"valid": true |
| 103 |
}, |
| 104 |
{ |
| 105 |
"description": "one minute duration", |
| 106 |
"data": "PT1M", |
| 107 |
"valid": true |
| 108 |
}, |
| 109 |
{ |
| 110 |
"description": "one and a half days, in hours", |
| 111 |
"data": "PT36H", |
| 112 |
"valid": true |
| 113 |
}, |
| 114 |
{ |
| 115 |
"description": "one and a half days, in days and hours", |
| 116 |
"data": "P1DT12H", |
| 117 |
"valid": true |
| 118 |
}, |
| 119 |
{ |
| 120 |
"description": "two weeks", |
| 121 |
"data": "P2W", |
| 122 |
"valid": true |
| 123 |
}, |
| 124 |
{ |
| 125 |
"description": "weeks cannot be combined with other units", |
| 126 |
"data": "P1Y2W", |
| 127 |
"valid": false |
| 128 |
}, |
| 129 |
{ |
| 130 |
"description": "invalid non-ASCII '২' (a Bengali 2)", |
| 131 |
"data": "P২Y", |
| 132 |
"valid": false |
| 133 |
}, |
| 134 |
{ |
| 135 |
"description": "element without unit", |
| 136 |
"data": "P1", |
| 137 |
"valid": false |
| 138 |
} |
| 139 |
] |
| 140 |
} |
| 141 |
] |