| 1 | [ |
| 2 | { |
| 3 | "description": "one property is maximum for another", |
| 4 | "schema": { |
| 5 | "properties": { |
| 6 | "larger": {}, |
| 7 | "smallerOrEqual": { |
| 8 | "maximum": {"$data": "1/larger"} |
| 9 | } |
| 10 | } |
| 11 | }, |
| 12 | "tests": [ |
| 13 | { |
| 14 | "description": "below the maximum is valid", |
| 15 | "data": { |
| 16 | "larger": 3, |
| 17 | "smallerOrEqual": 2 |
| 18 | }, |
| 19 | "valid": true |
| 20 | }, |
| 21 | { |
| 22 | "description": "equal to the maximum is valid", |
| 23 | "data": { |
| 24 | "larger": 3, |
| 25 | "smallerOrEqual": 3 |
| 26 | }, |
| 27 | "valid": true |
| 28 | }, |
| 29 | { |
| 30 | "description": "above the maximum is invalid", |
| 31 | "data": { |
| 32 | "larger": 3, |
| 33 | "smallerOrEqual": 4 |
| 34 | }, |
| 35 | "valid": false |
| 36 | }, |
| 37 | { |
| 38 | "description": "ignores non-numbers", |
| 39 | "data": { |
| 40 | "larger": 3, |
| 41 | "smallerOrEqual": "4" |
| 42 | }, |
| 43 | "valid": true |
| 44 | }, |
| 45 | { |
| 46 | "description": "fails if value of maximum is not number", |
| 47 | "data": { |
| 48 | "larger": "3", |
| 49 | "smallerOrEqual": 2 |
| 50 | }, |
| 51 | "valid": false |
| 52 | }, |
| 53 | { |
| 54 | "description": "valid if value of maximum is undefined", |
| 55 | "data": { |
| 56 | "smallerOrEqual": 2 |
| 57 | }, |
| 58 | "valid": true |
| 59 | } |
| 60 | ] |
| 61 | }, |
| 62 | { |
| 63 | "description": "exclusiveMaximum is $data", |
| 64 | "schema": { |
| 65 | "properties": { |
| 66 | "number": { |
| 67 | "maximum": 5, |
| 68 | "exclusiveMaximum": {"$data": "1/exclusiveMaximum"} |
| 69 | }, |
| 70 | "exclusiveMaximum": {} |
| 71 | } |
| 72 | }, |
| 73 | "tests": [ |
| 74 | { |
| 75 | "description": "exclusiveMaximum boolean no longer supported", |
| 76 | "data": { |
| 77 | "number": 4, |
| 78 | "exclusiveMaximum": true |
| 79 | }, |
| 80 | "valid": false |
| 81 | }, |
| 82 | { |
| 83 | "description": "below the maximum is valid when exclusiveMaximum is strictly larger", |
| 84 | "data": { |
| 85 | "number": 4, |
| 86 | "exclusiveMaximum": 4.1 |
| 87 | }, |
| 88 | "valid": true |
| 89 | }, |
| 90 | { |
| 91 | "description": "below the maximum is NOT valid when exclusiveMaximum is equal", |
| 92 | "data": { |
| 93 | "number": 4, |
| 94 | "exclusiveMaximum": 4 |
| 95 | }, |
| 96 | "valid": false |
| 97 | }, |
| 98 | { |
| 99 | "description": "below the maximum is valid when exclusiveMaximum is undefined", |
| 100 | "data": { |
| 101 | "number": 4 |
| 102 | }, |
| 103 | "valid": true |
| 104 | }, |
| 105 | { |
| 106 | "description": "boundary point is invalid when exclusiveMaximum is equal", |
| 107 | "data": { |
| 108 | "number": 3, |
| 109 | "exclusiveMaximum": 3 |
| 110 | }, |
| 111 | "valid": false |
| 112 | }, |
| 113 | { |
| 114 | "description": "boundary point is valid when exclusiveMaximum is smaller", |
| 115 | "data": { |
| 116 | "number": 3, |
| 117 | "exclusiveMaximum": 3.1 |
| 118 | }, |
| 119 | "valid": true |
| 120 | }, |
| 121 | { |
| 122 | "description": "boundary point is valid when exclusiveMaximum is undefined", |
| 123 | "data": { |
| 124 | "number": 3 |
| 125 | }, |
| 126 | "valid": true |
| 127 | }, |
| 128 | { |
| 129 | "description": "above the maximum is invalid", |
| 130 | "data": { |
| 131 | "number": 6 |
| 132 | }, |
| 133 | "valid": false |
| 134 | }, |
| 135 | { |
| 136 | "description": "fails if value of exclusiveMaximum is not number", |
| 137 | "data": { |
| 138 | "number": 4, |
| 139 | "exclusiveMaximum": "5" |
| 140 | }, |
| 141 | "valid": false |
| 142 | } |
| 143 | ] |
| 144 | }, |
| 145 | { |
| 146 | "description": "maximum and exclusiveMaximum are $data", |
| 147 | "schema": { |
| 148 | "properties": { |
| 149 | "larger": {}, |
| 150 | "smallerOrEqual": { |
| 151 | "maximum": {"$data": "1/larger"}, |
| 152 | "exclusiveMaximum": {"$data": "1/exclusiveMaximum"} |
| 153 | }, |
| 154 | "exclusiveMaximum": {} |
| 155 | } |
| 156 | }, |
| 157 | "tests": [ |
| 158 | { |
| 159 | "description": "exclusiveMaximum boolean no longer supported", |
| 160 | "data": { |
| 161 | "larger": 3, |
| 162 | "smallerOrEqual": 2, |
| 163 | "exclusiveMaximum": true |
| 164 | }, |
| 165 | "valid": false |
| 166 | }, |
| 167 | { |
| 168 | "description": "below the maximum is valid when exclusiveMaximum is strictly larger", |
| 169 | "data": { |
| 170 | "larger": 3, |
| 171 | "smallerOrEqual": 2, |
| 172 | "exclusiveMaximum": 2.1 |
| 173 | }, |
| 174 | "valid": true |
| 175 | }, |
| 176 | { |
| 177 | "description": "below the maximum is NOT valid when exclusiveMaximum is equal", |
| 178 | "data": { |
| 179 | "larger": 3, |
| 180 | "smallerOrEqual": 2, |
| 181 | "exclusiveMaximum": 2 |
| 182 | }, |
| 183 | "valid": false |
| 184 | }, |
| 185 | { |
| 186 | "description": "below the maximum is valid when exclusiveMaximum is undefined", |
| 187 | "data": { |
| 188 | "larger": 3, |
| 189 | "smallerOrEqual": 2 |
| 190 | }, |
| 191 | "valid": true |
| 192 | }, |
| 193 | { |
| 194 | "description": "above the maximum is invalid", |
| 195 | "data": { |
| 196 | "larger": 3, |
| 197 | "smallerOrEqual": 4, |
| 198 | "exclusiveMaximum": 5 |
| 199 | }, |
| 200 | "valid": false |
| 201 | }, |
| 202 | { |
| 203 | "description": "above the maximum is invalid when exclusiveMaximum is undefined", |
| 204 | "data": { |
| 205 | "larger": 3, |
| 206 | "smallerOrEqual": 4 |
| 207 | }, |
| 208 | "valid": false |
| 209 | }, |
| 210 | { |
| 211 | "description": "fails if value of exclusiveMaximum is not number", |
| 212 | "data": { |
| 213 | "larger": 3, |
| 214 | "smallerOrEqual": 2, |
| 215 | "exclusiveMaximum": "5" |
| 216 | }, |
| 217 | "valid": false |
| 218 | }, |
| 219 | { |
| 220 | "description": "boundary point is valid when exclusiveMaximum is strictly larger", |
| 221 | "data": { |
| 222 | "larger": 3, |
| 223 | "smallerOrEqual": 3, |
| 224 | "exclusiveMaximum": 3.1 |
| 225 | }, |
| 226 | "valid": true |
| 227 | }, |
| 228 | { |
| 229 | "description": "boundary point is invalid when exclusiveMaximum is equal", |
| 230 | "data": { |
| 231 | "larger": 3, |
| 232 | "smallerOrEqual": 3, |
| 233 | "exclusiveMaximum": 3 |
| 234 | }, |
| 235 | "valid": false |
| 236 | }, |
| 237 | { |
| 238 | "description": "boundary point is valid when exclusiveMaximum is undefined", |
| 239 | "data": { |
| 240 | "larger": 3, |
| 241 | "smallerOrEqual": 3 |
| 242 | }, |
| 243 | "valid": true |
| 244 | } |
| 245 | ] |
| 246 | }, |
| 247 | { |
| 248 | "description": "items in array are <= than their indeces", |
| 249 | "schema": { |
| 250 | "items": { |
| 251 | "maximum": {"$data": "0#"} |
| 252 | } |
| 253 | }, |
| 254 | "tests": [ |
| 255 | { |
| 256 | "description": "valid array", |
| 257 | "data": [0, 1, 1, 2, 2, 4], |
| 258 | "valid": true |
| 259 | }, |
| 260 | { |
| 261 | "description": "invalid array (2>1)", |
| 262 | "data": [0, 2], |
| 263 | "valid": false |
| 264 | } |
| 265 | ] |
| 266 | } |
| 267 | ] |