Debian Codegraph @

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

raw ◀ ▶
1 Debian patch touch this file
•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 true does not match 1",
159 "schema": {"enum": [true]},
160 "tests": [
161 {
162 "description": "true is valid",
163 "data": true,
164 "valid": true
165 },
166 {
167 "description": "integer one is invalid",
168 "data": 1,
169 "valid": false
170 },
171 {
172 "description": "float one is invalid",
173 "data": 1.0,
174 "valid": false
175 }
176 ]
177 },
178 {
179 "description": "enum with 0 does not match false",
180 "schema": {"enum": [0]},
181 "tests": [
182 {
183 "description": "false is invalid",
184 "data": false,
185 "valid": false
186 },
187 {
188 "description": "integer zero is valid",
189 "data": 0,
190 "valid": true
191 },
192 {
193 "description": "float zero is valid",
194 "data": 0.0,
195 "valid": true
196 }
197 ]
198 },
199 {
200 "description": "enum with 1 does not match true",
201 "schema": {"enum": [1]},
202 "tests": [
203 {
204 "description": "true is invalid",
205 "data": true,
206 "valid": false
207 },
208 {
209 "description": "integer one is valid",
210 "data": 1,
211 "valid": true
212 },
213 {
214 "description": "float one is valid",
215 "data": 1.0,
216 "valid": true
217 }
218 ]
219 },
220 {
221 "description": "nul characters in strings",
222 "schema": { "enum": [ "hello\u0000there" ] },
223 "tests": [
224 {
225 "description": "match string with nul",
226 "data": "hello\u0000there",
227 "valid": true
228 },
229 {
230 "description": "do not match string lacking nul",
231 "data": "hellothere",
232 "valid": false
233 }
234 ]
235 }
236 ]