Debian Codegraph @

bin/jsonschema/tests/draft3/type.json

raw
1 [
2 {
3 "description": "integer type matches integers",
4 "schema": {"type": "integer"},
5 "tests": [
6 {
7 "description": "an integer is an integer",
8 "data": 1,
9 "valid": true
10 },
11 {
12 "description": "a float is not an integer",
13 "data": 1.1,
14 "valid": false
15 },
16 {
17 "description": "a string is not an integer",
18 "data": "foo",
19 "valid": false
20 },
21 {
22 "description": "an object is not an integer",
23 "data": {},
24 "valid": false
25 },
26 {
27 "description": "an array is not an integer",
28 "data": [],
29 "valid": false
30 },
31 {
32 "description": "a boolean is not an integer",
33 "data": true,
34 "valid": false
35 },
36 {
37 "description": "null is not an integer",
38 "data": null,
39 "valid": false
40 }
41 ]
42 },
43 {
44 "description": "number type matches numbers",
45 "schema": {"type": "number"},
46 "tests": [
47 {
48 "description": "an integer is a number",
49 "data": 1,
50 "valid": true
51 },
52 {
53 "description": "a float is a number",
54 "data": 1.1,
55 "valid": true
56 },
57 {
58 "description": "a string is not a number",
59 "data": "foo",
60 "valid": false
61 },
62 {
63 "description": "an object is not a number",
64 "data": {},
65 "valid": false
66 },
67 {
68 "description": "an array is not a number",
69 "data": [],
70 "valid": false
71 },
72 {
73 "description": "a boolean is not a number",
74 "data": true,
75 "valid": false
76 },
77 {
78 "description": "null is not a number",
79 "data": null,
80 "valid": false
81 }
82 ]
83 },
84 {
85 "description": "string type matches strings",
86 "schema": {"type": "string"},
87 "tests": [
88 {
89 "description": "1 is not a string",
90 "data": 1,
91 "valid": false
92 },
93 {
94 "description": "a float is not a string",
95 "data": 1.1,
96 "valid": false
97 },
98 {
99 "description": "a string is a string",
100 "data": "foo",
101 "valid": true
102 },
103 {
104 "description": "an object is not a string",
105 "data": {},
106 "valid": false
107 },
108 {
109 "description": "an array is not a string",
110 "data": [],
111 "valid": false
112 },
113 {
114 "description": "a boolean is not a string",
115 "data": true,
116 "valid": false
117 },
118 {
119 "description": "null is not a string",
120 "data": null,
121 "valid": false
122 }
123 ]
124 },
125 {
126 "description": "object type matches objects",
127 "schema": {"type": "object"},
128 "tests": [
129 {
130 "description": "an integer is not an object",
131 "data": 1,
132 "valid": false
133 },
134 {
135 "description": "a float is not an object",
136 "data": 1.1,
137 "valid": false
138 },
139 {
140 "description": "a string is not an object",
141 "data": "foo",
142 "valid": false
143 },
144 {
145 "description": "an object is an object",
146 "data": {},
147 "valid": true
148 },
149 {
150 "description": "an array is not an object",
151 "data": [],
152 "valid": false
153 },
154 {
155 "description": "a boolean is not an object",
156 "data": true,
157 "valid": false
158 },
159 {
160 "description": "null is not an object",
161 "data": null,
162 "valid": false
163 }
164 ]
165 },
166 {
167 "description": "array type matches arrays",
168 "schema": {"type": "array"},
169 "tests": [
170 {
171 "description": "an integer is not an array",
172 "data": 1,
173 "valid": false
174 },
175 {
176 "description": "a float is not an array",
177 "data": 1.1,
178 "valid": false
179 },
180 {
181 "description": "a string is not an array",
182 "data": "foo",
183 "valid": false
184 },
185 {
186 "description": "an object is not an array",
187 "data": {},
188 "valid": false
189 },
190 {
191 "description": "an array is an array",
192 "data": [],
193 "valid": true
194 },
195 {
196 "description": "a boolean is not an array",
197 "data": true,
198 "valid": false
199 },
200 {
201 "description": "null is not an array",
202 "data": null,
203 "valid": false
204 }
205 ]
206 },
207 {
208 "description": "boolean type matches booleans",
209 "schema": {"type": "boolean"},
210 "tests": [
211 {
212 "description": "an integer is not a boolean",
213 "data": 1,
214 "valid": false
215 },
216 {
217 "description": "a float is not a boolean",
218 "data": 1.1,
219 "valid": false
220 },
221 {
222 "description": "a string is not a boolean",
223 "data": "foo",
224 "valid": false
225 },
226 {
227 "description": "an object is not a boolean",
228 "data": {},
229 "valid": false
230 },
231 {
232 "description": "an array is not a boolean",
233 "data": [],
234 "valid": false
235 },
236 {
237 "description": "a boolean is a boolean",
238 "data": true,
239 "valid": true
240 },
241 {
242 "description": "null is not a boolean",
243 "data": null,
244 "valid": false
245 }
246 ]
247 },
248 {
249 "description": "null type matches only the null object",
250 "schema": {"type": "null"},
251 "tests": [
252 {
253 "description": "an integer is not null",
254 "data": 1,
255 "valid": false
256 },
257 {
258 "description": "a float is not null",
259 "data": 1.1,
260 "valid": false
261 },
262 {
263 "description": "a string is not null",
264 "data": "foo",
265 "valid": false
266 },
267 {
268 "description": "an object is not null",
269 "data": {},
270 "valid": false
271 },
272 {
273 "description": "an array is not null",
274 "data": [],
275 "valid": false
276 },
277 {
278 "description": "a boolean is not null",
279 "data": true,
280 "valid": false
281 },
282 {
283 "description": "null is null",
284 "data": null,
285 "valid": true
286 }
287 ]
288 },
289 {
290 "description": "any type matches any type",
291 "schema": {"type": "any"},
292 "tests": [
293 {
294 "description": "any type includes integers",
295 "data": 1,
296 "valid": true
297 },
298 {
299 "description": "any type includes float",
300 "data": 1.1,
301 "valid": true
302 },
303 {
304 "description": "any type includes string",
305 "data": "foo",
306 "valid": true
307 },
308 {
309 "description": "any type includes object",
310 "data": {},
311 "valid": true
312 },
313 {
314 "description": "any type includes array",
315 "data": [],
316 "valid": true
317 },
318 {
319 "description": "any type includes boolean",
320 "data": true,
321 "valid": true
322 },
323 {
324 "description": "any type includes null",
325 "data": null,
326 "valid": true
327 }
328 ]
329 },
330 {
331 "description": "multiple types can be specified in an array",
332 "schema": {"type": ["integer", "string"]},
333 "tests": [
334 {
335 "description": "an integer is valid",
336 "data": 1,
337 "valid": true
338 },
339 {
340 "description": "a string is valid",
341 "data": "foo",
342 "valid": true
343 },
344 {
345 "description": "a float is invalid",
346 "data": 1.1,
347 "valid": false
348 },
349 {
350 "description": "an object is invalid",
351 "data": {},
352 "valid": false
353 },
354 {
355 "description": "an array is invalid",
356 "data": [],
357 "valid": false
358 },
359 {
360 "description": "a boolean is invalid",
361 "data": true,
362 "valid": false
363 },
364 {
365 "description": "null is invalid",
366 "data": null,
367 "valid": false
368 }
369 ]
370 },
371 {
372 "description": "types can include schemas",
373 "schema": {
374 "type": [
375 "array",
376 {"type": "object"}
377 ]
378 },
379 "tests": [
380 {
381 "description": "an integer is invalid",
382 "data": 1,
383 "valid": false
384 },
385 {
386 "description": "a string is invalid",
387 "data": "foo",
388 "valid": false
389 },
390 {
391 "description": "a float is invalid",
392 "data": 1.1,
393 "valid": false
394 },
395 {
396 "description": "an object is valid",
397 "data": {},
398 "valid": true
399 },
400 {
401 "description": "an array is valid",
402 "data": [],
403 "valid": true
404 },
405 {
406 "description": "a boolean is invalid",
407 "data": true,
408 "valid": false
409 },
410 {
411 "description": "null is invalid",
412 "data": null,
413 "valid": false
414 }
415 ]
416 },
417 {
418 "description":
419 "when types includes a schema it should fully validate the schema",
420 "schema": {
421 "type": [
422 "integer",
423 {
424 "properties": {
425 "foo": {"type": "null"}
426 }
427 }
428 ]
429 },
430 "tests": [
431 {
432 "description": "an integer is valid",
433 "data": 1,
434 "valid": true
435 },
436 {
437 "description": "an object is valid only if it is fully valid",
438 "data": {"foo": null},
439 "valid": true
440 },
441 {
442 "description": "an object is invalid otherwise",
443 "data": {"foo": "bar"},
444 "valid": false
445 }
446 ]
447 },
448 {
449 "description": "types from separate schemas are merged",
450 "schema": {
451 "type": [
452 {"type": ["string"]},
453 {"type": ["array", "null"]}
454 ]
455 },
456 "tests": [
457 {
458 "description": "an integer is invalid",
459 "data": 1,
460 "valid": false
461 },
462 {
463 "description": "a string is valid",
464 "data": "foo",
465 "valid": true
466 },
467 {
468 "description": "an array is valid",
469 "data": [1, 2, 3],
470 "valid": true
471 }
472 ]
473 }
474 ]