Debian Codegraph @

share/tests/draft7/enum.json

raw
1 [
2 {
3 "description": "simple enum validation",
4 "schema": {"enum": [1, 2, 3]},
5 "tests": [
6 {
7 "description": "one of the enum is valid",
8 "data": 1,
9 "valid": true
10 },
11 {
12 "description": "something else is invalid",
13 "data": 4,
14 "valid": false
15 }
16 ]
17 },
18 {
19 "description": "heterogeneous enum validation",
20 "schema": {"enum": [6, "foo", [], true, {"foo": 12}]},
21 "tests": [
22 {
23 "description": "one of the enum is valid",
24 "data": [],
25 "valid": true
26 },
27 {
28 "description": "something else is invalid",
29 "data": null,
30 "valid": false
31 },
32 {
33 "description": "objects are deep compared",
34 "data": {"foo": false},
35 "valid": false
36 },
37 {
38 "description": "valid object matches",
39 "data": {"foo": 12},
40 "valid": true
41 },
42 {
43 "description": "extra properties in object is invalid",
44 "data": {"foo": 12, "boo": 42},
45 "valid": false
46 }
47 ]
48 },
49 {
50 "description": "heterogeneous enum-with-null validation",
51 "schema": { "enum": [6, null] },
52 "tests": [
53 {
54 "description": "null is valid",
55 "data": null,
56 "valid": true
57 },
58 {
59 "description": "number is valid",
60 "data": 6,
61 "valid": true
62 },
63 {
64 "description": "something else is invalid",
65 "data": "test",
66 "valid": false
67 }
68 ]
69 },
70 {
71 "description": "enums in properties",
72 "schema": {
73 "type":"object",
74 "properties": {
75 "foo": {"enum":["foo"]},
76 "bar": {"enum":["bar"]}
77 },
78 "required": ["bar"]
79 },
80 "tests": [
81 {
82 "description": "both properties are valid",
83 "data": {"foo":"foo", "bar":"bar"},
84 "valid": true
85 },
86 {
87 "description": "wrong foo value",
88 "data": {"foo":"foot", "bar":"bar"},
89 "valid": false
90 },
91 {
92 "description": "wrong bar value",
93 "data": {"foo":"foo", "bar":"bart"},
94 "valid": false
95 },
96 {
97 "description": "missing optional property is valid",
98 "data": {"bar":"bar"},
99 "valid": true
100 },
101 {
102 "description": "missing required property is invalid",
103 "data": {"foo":"foo"},
104 "valid": false
105 },
106 {
107 "description": "missing all properties is invalid",
108 "data": {},
109 "valid": false
110 }
111 ]
112 },
113 {
114 "description": "enum with escaped characters",
115 "schema": {
116 "enum": ["foo\nbar", "foo\rbar"]
117 },
118 "tests": [
119 {
120 "description": "member 1 is valid",
121 "data": "foo\nbar",
122 "valid": true
123 },
124 {
125 "description": "member 2 is valid",
126 "data": "foo\rbar",
127 "valid": true
128 },
129 {
130 "description": "another string is invalid",
131 "data": "abc",
132 "valid": false
133 }
134 ]
135 },
136 {
137 "description": "enum with false does not match 0",
138 "schema": {"enum": [false]},
139 "tests": [
140 {
141 "description": "false is valid",
142 "data": false,
143 "valid": true
144 },
145 {
146 "description": "integer zero is invalid",
147 "data": 0,
148 "valid": false
149 },
150 {
151 "description": "float zero is invalid",
152 "data": 0.0,
153 "valid": false
154 }
155 ]
156 },
157 {
158 "description": "enum with [false] does not match [0]",
159 "schema": {"enum": [[false]]},
160 "tests": [
161 {
162 "description": "[false] is valid",
163 "data": [false],
164 "valid": true
165 },
166 {
167 "description": "[0] is invalid",
168 "data": [0],
169 "valid": false
170 },
171 {
172 "description": "[0.0] is invalid",
173 "data": [0.0],
174 "valid": false
175 }
176 ]
177 },
178 {
179 "description": "enum with true does not match 1",
180 "schema": {"enum": [true]},
181 "tests": [
182 {
183 "description": "true is valid",
184 "data": true,
185 "valid": true
186 },
187 {
188 "description": "integer one is invalid",
189 "data": 1,
190 "valid": false
191 },
192 {
193 "description": "float one is invalid",
194 "data": 1.0,
195 "valid": false
196 }
197 ]
198 },
199 {
200 "description": "enum with [true] does not match [1]",
201 "schema": {"enum": [[true]]},
202 "tests": [
203 {
204 "description": "[true] is valid",
205 "data": [true],
206 "valid": true
207 },
208 {
209 "description": "[1] is invalid",
210 "data": [1],
211 "valid": false
212 },
213 {
214 "description": "[1.0] is invalid",
215 "data": [1.0],
216 "valid": false
217 }
218 ]
219 },
220 {
221 "description": "enum with 0 does not match false",
222 "schema": {"enum": [0]},
223 "tests": [
224 {
225 "description": "false is invalid",
226 "data": false,
227 "valid": false
228 },
229 {
230 "description": "integer zero is valid",
231 "data": 0,
232 "valid": true
233 },
234 {
235 "description": "float zero is valid",
236 "data": 0.0,
237 "valid": true
238 }
239 ]
240 },
241 {
242 "description": "enum with [0] does not match [false]",
243 "schema": {"enum": [[0]]},
244 "tests": [
245 {
246 "description": "[false] is invalid",
247 "data": [false],
248 "valid": false
249 },
250 {
251 "description": "[0] is valid",
252 "data": [0],
253 "valid": true
254 },
255 {
256 "description": "[0.0] is valid",
257 "data": [0.0],
258 "valid": true
259 }
260 ]
261 },
262 {
263 "description": "enum with 1 does not match true",
264 "schema": {"enum": [1]},
265 "tests": [
266 {
267 "description": "true is invalid",
268 "data": true,
269 "valid": false
270 },
271 {
272 "description": "integer one is valid",
273 "data": 1,
274 "valid": true
275 },
276 {
277 "description": "float one is valid",
278 "data": 1.0,
279 "valid": true
280 }
281 ]
282 },
283 {
284 "description": "enum with [1] does not match [true]",
285 "schema": {"enum": [[1]]},
286 "tests": [
287 {
288 "description": "[true] is invalid",
289 "data": [true],
290 "valid": false
291 },
292 {
293 "description": "[1] is valid",
294 "data": [1],
295 "valid": true
296 },
297 {
298 "description": "[1.0] is valid",
299 "data": [1.0],
300 "valid": true
301 }
302 ]
303 },
304 {
305 "description": "nul characters in strings",
306 "schema": { "enum": [ "hello\u0000there" ] },
307 "tests": [
308 {
309 "description": "match string with nul",
310 "data": "hello\u0000there",
311 "valid": true
312 },
313 {
314 "description": "do not match string lacking nul",
315 "data": "hellothere",
316 "valid": false
317 }
318 ]
319 },
320 {
321 "description": "characters with the same visual representation, but different number of codepoints",
322 "schema": {
323 "enum": ["ä"],
324 "$comment": "U+00E4"
325 },
326 "tests": [
327 {
328 "description": "character uses the same codepoint",
329 "data": "ä",
330 "comment": "U+00E4",
331 "valid": true
332 },
333 {
334 "description": "character looks the same but uses combining marks",
335 "data": "ä",
336 "comment": "a, U+0308",
337 "valid": false
338 }
339 ]
340 }
341 ]