Debian Codegraph @

spec/JSON-Schema-Test-Suite/tests/draft2020-12/unevaluatedItems.json

raw ◀ ▶
1 Debian patch touch this file
•1 [
2 {
3 "description": "unevaluatedItems true",
4 "schema": {
5 "type": "array",
6 "unevaluatedItems": true
7 },
8 "tests": [
9 {
10 "description": "with no unevaluated items",
11 "data": [],
12 "valid": true
13 },
14 {
15 "description": "with unevaluated items",
16 "data": ["foo"],
17 "valid": true
18 }
19 ]
20 },
21 {
22 "description": "unevaluatedItems false",
23 "schema": {
24 "type": "array",
25 "unevaluatedItems": false
26 },
27 "tests": [
28 {
29 "description": "with no unevaluated items",
30 "data": [],
31 "valid": true
32 },
33 {
34 "description": "with unevaluated items",
35 "data": ["foo"],
36 "valid": false
37 }
38 ]
39 },
40 {
41 "description": "unevaluatedItems as schema",
42 "schema": {
43 "type": "array",
44 "unevaluatedItems": { "type": "string" }
45 },
46 "tests": [
47 {
48 "description": "with no unevaluated items",
49 "data": [],
50 "valid": true
51 },
52 {
53 "description": "with valid unevaluated items",
54 "data": ["foo"],
55 "valid": true
56 },
57 {
58 "description": "with invalid unevaluated items",
59 "data": [42],
60 "valid": false
61 }
62 ]
63 },
64 {
65 "description": "unevaluatedItems with uniform items",
66 "schema": {
67 "type": "array",
68 "items": { "type": "string" },
69 "unevaluatedItems": false
70 },
71 "tests": [
72 {
73 "description": "unevaluatedItems doesn't apply",
74 "data": ["foo", "bar"],
75 "valid": true
76 }
77 ]
78 },
79 {
80 "description": "unevaluatedItems with tuple",
81 "schema": {
82 "type": "array",
83 "prefixItems": [
84 { "type": "string" }
85 ],
86 "unevaluatedItems": false
87 },
88 "tests": [
89 {
90 "description": "with no unevaluated items",
91 "data": ["foo"],
92 "valid": true
93 },
94 {
95 "description": "with unevaluated items",
96 "data": ["foo", "bar"],
97 "valid": false
98 }
99 ]
100 },
101 {
102 "description": "unevaluatedItems with items",
103 "schema": {
104 "type": "array",
105 "prefixItems": [
106 { "type": "string" }
107 ],
108 "items": true,
109 "unevaluatedItems": false
110 },
111 "tests": [
112 {
113 "description": "unevaluatedItems doesn't apply",
114 "data": ["foo", 42],
115 "valid": true
116 }
117 ]
118 },
119 {
120 "description": "unevaluatedItems with nested tuple",
121 "schema": {
122 "type": "array",
123 "prefixItems": [
124 { "type": "string" }
125 ],
126 "allOf": [
127 {
128 "prefixItems": [
129 true,
130 { "type": "number" }
131 ]
132 }
133 ],
134 "unevaluatedItems": false
135 },
136 "tests": [
137 {
138 "description": "with no unevaluated items",
139 "data": ["foo", 42],
140 "valid": true
141 },
142 {
143 "description": "with unevaluated items",
144 "data": ["foo", 42, true],
145 "valid": false
146 }
147 ]
148 },
149 {
150 "description": "unevaluatedItems with nested items",
151 "schema": {
152 "type": "array",
153 "allOf": [
154 {
155 "prefixItems": [
156 { "type": "string" }
157 ],
158 "items": true
159 }
160 ],
161 "unevaluatedItems": false
162 },
163 "tests": [
164 {
165 "description": "with no additional items",
166 "data": ["foo"],
167 "valid": true
168 },
169 {
170 "description": "with additional items",
171 "data": ["foo", 42, true],
172 "valid": true
173 }
174 ]
175 },
176 {
177 "description": "unevaluatedItems with nested unevaluatedItems",
178 "schema": {
179 "type": "array",
180 "allOf": [
181 {
182 "prefixItems": [
183 { "type": "string" }
184 ]
185 },
186 {
187 "unevaluatedItems": true
188 }
189 ],
190 "unevaluatedItems": false
191 },
192 "tests": [
193 {
194 "description": "with no additional items",
195 "data": ["foo"],
196 "valid": true
197 },
198 {
199 "description": "with additional items",
200 "data": ["foo", 42, true],
201 "valid": true
202 }
203 ]
204 },
205 {
206 "description": "unevaluatedItems with anyOf",
207 "schema": {
208 "type": "array",
209 "prefixItems": [
210 { "const": "foo" }
211 ],
212 "anyOf": [
213 {
214 "prefixItems": [
215 true,
216 { "const": "bar" }
217 ]
218 },
219 {
220 "prefixItems": [
221 true,
222 true,
223 { "const": "baz" }
224 ]
225 }
226 ],
227 "unevaluatedItems": false
228 },
229 "tests": [
230 {
231 "description": "when one schema matches and has no unevaluated items",
232 "data": ["foo", "bar"],
233 "valid": true
234 },
235 {
236 "description": "when one schema matches and has unevaluated items",
237 "data": ["foo", "bar", 42],
238 "valid": false
239 },
240 {
241 "description": "when two schemas match and has no unevaluated items",
242 "data": ["foo", "bar", "baz"],
243 "valid": true
244 },
245 {
246 "description": "when two schemas match and has unevaluated items",
247 "data": ["foo", "bar", "baz", 42],
248 "valid": false
249 }
250 ]
251 },
252 {
253 "description": "unevaluatedItems with oneOf",
254 "schema": {
255 "type": "array",
256 "prefixItems": [
257 { "const": "foo" }
258 ],
259 "oneOf": [
260 {
261 "prefixItems": [
262 true,
263 { "const": "bar" }
264 ]
265 },
266 {
267 "prefixItems": [
268 true,
269 { "const": "baz" }
270 ]
271 }
272 ],
273 "unevaluatedItems": false
274 },
275 "tests": [
276 {
277 "description": "with no unevaluated items",
278 "data": ["foo", "bar"],
279 "valid": true
280 },
281 {
282 "description": "with unevaluated items",
283 "data": ["foo", "bar", 42],
284 "valid": false
285 }
286 ]
287 },
288 {
289 "description": "unevaluatedItems with not",
290 "schema": {
291 "type": "array",
292 "prefixItems": [
293 { "const": "foo" }
294 ],
295 "not": {
296 "not": {
297 "prefixItems": [
298 true,
299 { "const": "bar" }
300 ]
301 }
302 },
303 "unevaluatedItems": false
304 },
305 "tests": [
306 {
307 "description": "with unevaluated items",
308 "data": ["foo", "bar"],
309 "valid": false
310 }
311 ]
312 },
313 {
314 "description": "unevaluatedItems with if/then/else",
315 "schema": {
316 "type": "array",
317 "prefixItems": [
318 { "const": "foo" }
319 ],
320 "if": {
321 "prefixItems": [
322 true,
323 { "const": "bar" }
324 ]
325 },
326 "then": {
327 "prefixItems": [
328 true,
329 true,
330 { "const": "then" }
331 ]
332 },
333 "else": {
334 "prefixItems": [
335 true,
336 true,
337 true,
338 { "const": "else" }
339 ]
340 },
341 "unevaluatedItems": false
342 },
343 "tests": [
344 {
345 "description": "when if matches and it has no unevaluated items",
346 "data": ["foo", "bar", "then"],
347 "valid": true
348 },
349 {
350 "description": "when if matches and it has unevaluated items",
351 "data": ["foo", "bar", "then", "else"],
352 "valid": false
353 },
354 {
355 "description": "when if doesn't match and it has no unevaluated items",
356 "data": ["foo", 42, 42, "else"],
357 "valid": true
358 },
359 {
360 "description": "when if doesn't match and it has unevaluated items",
361 "data": ["foo", 42, 42, "else", 42],
362 "valid": false
363 }
364 ]
365 },
366 {
367 "description": "unevaluatedItems with boolean schemas",
368 "schema": {
369 "type": "array",
370 "allOf": [true],
371 "unevaluatedItems": false
372 },
373 "tests": [
374 {
375 "description": "with no unevaluated items",
376 "data": [],
377 "valid": true
378 },
379 {
380 "description": "with unevaluated items",
381 "data": ["foo"],
382 "valid": false
383 }
384 ]
385 },
386 {
387 "description": "unevaluatedItems with $ref",
388 "schema": {
389 "type": "array",
390 "$ref": "#/$defs/bar",
391 "prefixItems": [
392 { "type": "string" }
393 ],
394 "unevaluatedItems": false,
395 "$defs": {
396 "bar": {
397 "prefixItems": [
398 true,
399 { "type": "string" }
400 ]
401 }
402 }
403 },
404 "tests": [
405 {
406 "description": "with no unevaluated items",
407 "data": ["foo", "bar"],
408 "valid": true
409 },
410 {
411 "description": "with unevaluated items",
412 "data": ["foo", "bar", "baz"],
413 "valid": false
414 }
415 ]
416 },
417 {
418 "description": "unevaluatedItems can't see inside cousins",
419 "schema": {
420 "allOf": [
421 {
422 "prefixItems": [ true ]
423 },
424 {
425 "unevaluatedItems": false
426 }
427 ]
428 },
429 "tests": [
430 {
431 "description": "always fails",
432 "data": [ 1 ],
433 "valid": false
434 }
435 ]
436 },
437 {
438 "description": "item is evaluated in an uncle schema to unevaluatedItems",
439 "schema": {
440 "type": "object",
441 "properties": {
442 "foo": {
443 "type": "array",
444 "prefixItems": [
445 {
446 "type": "string"
447 }
448 ],
449 "unevaluatedItems": false
450 }
451 },
452 "anyOf": [
453 {
454 "properties": {
455 "foo": {
456 "prefixItems": [
457 true,
458 {
459 "type": "string"
460 }
461 ]
462 }
463 }
464 }
465 ]
466 },
467 "tests": [
468 {
469 "description": "no extra items",
470 "data": {
471 "foo": [
472 "test"
473 ]
474 },
475 "valid": true
476 },
477 {
478 "description": "uncle keyword evaluation is not significant",
479 "data": {
480 "foo": [
481 "test",
482 "test"
483 ]
484 },
485 "valid": false
486 }
487 ]
488 },
489 {
490 "description": "unevaluatedItems depends on adjacent contains",
491 "schema": {
492 "prefixItems": [true],
493 "contains": {"type": "string"},
494 "unevaluatedItems": false
495 },
496 "tests": [
497 {
498 "description": "second item is evaluated by contains",
499 "data": [ 1, "foo" ],
500 "valid": true
501 },
502 {
503 "description": "contains fails, second item is not evaluated",
504 "data": [ 1, 2 ],
505 "valid": false
506 },
507 {
508 "description": "contains passes, second item is not evaluated",
509 "data": [ 1, 2, "foo" ],
510 "valid": false
511 }
512 ]
513 },
514 {
515 "description": "unevaluatedItems depends on multiple nested contains",
516 "schema": {
517 "allOf": [
518 { "contains": { "multipleOf": 2 } },
519 { "contains": { "multipleOf": 3 } }
520 ],
521 "unevaluatedItems": { "multipleOf": 5 }
522 },
523 "tests": [
524 {
525 "description": "5 not evaluated, passes unevaluatedItems",
526 "data": [ 2, 3, 4, 5, 6 ],
527 "valid": true
528 },
529 {
530 "description": "7 not evaluated, fails unevaluatedItems",
531 "data": [ 2, 3, 4, 7, 8 ],
532 "valid": false
533 }
534 ]
535 },
536 {
537 "description": "unevaluatedItems and contains interact to control item dependency relationship",
538 "schema": {
539 "if": {
540 "contains": {"const": "a"}
541 },
542 "then": {
543 "if": {
544 "contains": {"const": "b"}
545 },
546 "then": {
547 "if": {
548 "contains": {"const": "c"}
549 }
550 }
551 },
552 "unevaluatedItems": false
553 },
554 "tests": [
555 {
556 "description": "empty array is valid",
557 "data": [],
558 "valid": true
559 },
560 {
561 "description": "only a's are valid",
562 "data": [ "a", "a" ],
563 "valid": true
564 },
565 {
566 "description": "a's and b's are valid",
567 "data": [ "a", "b", "a", "b", "a" ],
568 "valid": true
569 },
570 {
571 "description": "a's, b's and c's are valid",
572 "data": [ "c", "a", "c", "c", "b", "a" ],
573 "valid": true
574 },
575 {
576 "description": "only b's are invalid",
577 "data": [ "b", "b" ],
578 "valid": false
579 },
580 {
581 "description": "only c's are invalid",
582 "data": [ "c", "c" ],
583 "valid": false
584 },
585 {
586 "description": "only b's and c's are invalid",
587 "data": [ "c", "b", "c", "b", "c" ],
588 "valid": false
589 },
590 {
591 "description": "only a's and c's are invalid",
592 "data": [ "c", "a", "c", "a", "c" ],
593 "valid": false
594 }
595 ]
596 }
597 ]