Debian Codegraph @

share/tests/draft4/additionalItems.json

raw
1 [
2 {
3 "description": "additionalItems as schema",
4 "schema": {
5 "items": [{}],
6 "additionalItems": {"type": "integer"}
7 },
8 "tests": [
9 {
10 "description": "additional items match schema",
11 "data": [ null, 2, 3, 4 ],
12 "valid": true
13 },
14 {
15 "description": "additional items do not match schema",
16 "data": [ null, 2, 3, "foo" ],
17 "valid": false
18 }
19 ]
20 },
21 {
22 "description": "when items is schema, additionalItems does nothing",
23 "schema": {
24 "items": {},
25 "additionalItems": false
26 },
27 "tests": [
28 {
29 "description": "all items match schema",
30 "data": [ 1, 2, 3, 4, 5 ],
31 "valid": true
32 }
33 ]
34 },
35 {
36 "description": "array of items with no additionalItems permitted",
37 "schema": {
38 "items": [{}, {}, {}],
39 "additionalItems": false
40 },
41 "tests": [
42 {
43 "description": "empty array",
44 "data": [ ],
45 "valid": true
46 },
47 {
48 "description": "fewer number of items present (1)",
49 "data": [ 1 ],
50 "valid": true
51 },
52 {
53 "description": "fewer number of items present (2)",
54 "data": [ 1, 2 ],
55 "valid": true
56 },
57 {
58 "description": "equal number of items present",
59 "data": [ 1, 2, 3 ],
60 "valid": true
61 },
62 {
63 "description": "additional items are not permitted",
64 "data": [ 1, 2, 3, 4 ],
65 "valid": false
66 }
67 ]
68 },
69 {
70 "description": "additionalItems as false without items",
71 "schema": {"additionalItems": false},
72 "tests": [
73 {
74 "description":
75 "items defaults to empty schema so everything is valid",
76 "data": [ 1, 2, 3, 4, 5 ],
77 "valid": true
78 },
79 {
80 "description": "ignores non-arrays",
81 "data": {"foo" : "bar"},
82 "valid": true
83 }
84 ]
85 },
86 {
87 "description": "additionalItems are allowed by default",
88 "schema": {"items": [{"type": "integer"}]},
89 "tests": [
90 {
91 "description": "only the first item is validated",
92 "data": [1, "foo", false],
93 "valid": true
94 }
95 ]
96 },
97 {
98 "description": "additionalItems does not look in applicators, invalid case",
99 "schema": {
100 "allOf": [
101 { "items": [ { "type": "integer" }, { "type": "string" } ] }
102 ],
103 "items": [ {"type": "integer" } ],
104 "additionalItems": { "type": "boolean" }
105 },
106 "tests": [
107 {
108 "description": "items defined in allOf are not examined",
109 "data": [ 1, "hello" ],
110 "valid": false
111 }
112 ]
113 },
114 {
115 "description": "items validation adjusts the starting index for additionalItems",
116 "schema": {
117 "items": [ { "type": "string" } ],
118 "additionalItems": { "type": "integer" }
119 },
120 "tests": [
121 {
122 "description": "valid items",
123 "data": [ "x", 2, 3 ],
124 "valid": true
125 },
126 {
127 "description": "wrong type of second item",
128 "data": [ "x", "y" ],
129 "valid": false
130 }
131 ]
132 },
133 {
134 "description": "additionalItems with heterogeneous array",
135 "schema": {
136 "items": [{}],
137 "additionalItems": false
138 },
139 "tests": [
140 {
141 "description": "heterogeneous invalid instance",
142 "data": [ "foo", "bar", 37 ],
143 "valid": false
144 },
145 {
146 "description": "valid instance",
147 "data": [ null ],
148 "valid": true
149 }
150 ]
151 },
152 {
153 "description": "additionalItems with null instance elements",
154 "schema": {
155 "additionalItems": {
156 "type": "null"
157 }
158 },
159 "tests": [
160 {
161 "description": "allows null elements",
162 "data": [ null ],
163 "valid": true
164 }
165 ]
166 }
167 ]