Debian Codegraph @

share/tests/draft4/anyOf.json

raw
1 [
2 {
3 "description": "anyOf",
4 "schema": {
5 "anyOf": [
6 {
7 "type": "integer"
8 },
9 {
10 "minimum": 2
11 }
12 ]
13 },
14 "tests": [
15 {
16 "description": "first anyOf valid",
17 "data": 1,
18 "valid": true
19 },
20 {
21 "description": "second anyOf valid",
22 "data": 2.5,
23 "valid": true
24 },
25 {
26 "description": "both anyOf valid",
27 "data": 3,
28 "valid": true
29 },
30 {
31 "description": "neither anyOf valid",
32 "data": 1.5,
33 "valid": false
34 }
35 ]
36 },
37 {
38 "description": "anyOf with base schema",
39 "schema": {
40 "type": "string",
41 "anyOf" : [
42 {
43 "maxLength": 2
44 },
45 {
46 "minLength": 4
47 }
48 ]
49 },
50 "tests": [
51 {
52 "description": "mismatch base schema",
53 "data": 3,
54 "valid": false
55 },
56 {
57 "description": "one anyOf valid",
58 "data": "foobar",
59 "valid": true
60 },
61 {
62 "description": "both anyOf invalid",
63 "data": "foo",
64 "valid": false
65 }
66 ]
67 },
68 {
69 "description": "anyOf complex types",
70 "schema": {
71 "anyOf": [
72 {
73 "properties": {
74 "bar": {"type": "integer"}
75 },
76 "required": ["bar"]
77 },
78 {
79 "properties": {
80 "foo": {"type": "string"}
81 },
82 "required": ["foo"]
83 }
84 ]
85 },
86 "tests": [
87 {
88 "description": "first anyOf valid (complex)",
89 "data": {"bar": 2},
90 "valid": true
91 },
92 {
93 "description": "second anyOf valid (complex)",
94 "data": {"foo": "baz"},
95 "valid": true
96 },
97 {
98 "description": "both anyOf valid (complex)",
99 "data": {"foo": "baz", "bar": 2},
100 "valid": true
101 },
102 {
103 "description": "neither anyOf valid (complex)",
104 "data": {"foo": 2, "bar": "quux"},
105 "valid": false
106 }
107 ]
108 },
109 {
110 "description": "anyOf with one empty schema",
111 "schema": {
112 "anyOf": [
113 { "type": "number" },
114 {}
115 ]
116 },
117 "tests": [
118 {
119 "description": "string is valid",
120 "data": "foo",
121 "valid": true
122 },
123 {
124 "description": "number is valid",
125 "data": 123,
126 "valid": true
127 }
128 ]
129 },
130 {
131 "description": "nested anyOf, to check validation semantics",
132 "schema": {
133 "anyOf": [
134 {
135 "anyOf": [
136 {
137 "type": "null"
138 }
139 ]
140 }
141 ]
142 },
143 "tests": [
144 {
145 "description": "null is valid",
146 "data": null,
147 "valid": true
148 },
149 {
150 "description": "anything non-null is invalid",
151 "data": 123,
152 "valid": false
153 }
154 ]
155 }
156 ]