Debian Codegraph @

share/tests/draft7/properties.json

raw
1 [
2 {
3 "description": "object properties validation",
4 "schema": {
5 "properties": {
6 "foo": {"type": "integer"},
7 "bar": {"type": "string"}
8 }
9 },
10 "tests": [
11 {
12 "description": "both properties present and valid is valid",
13 "data": {"foo": 1, "bar": "baz"},
14 "valid": true
15 },
16 {
17 "description": "one property invalid is invalid",
18 "data": {"foo": 1, "bar": {}},
19 "valid": false
20 },
21 {
22 "description": "both properties invalid is invalid",
23 "data": {"foo": [], "bar": {}},
24 "valid": false
25 },
26 {
27 "description": "doesn't invalidate other properties",
28 "data": {"quux": []},
29 "valid": true
30 },
31 {
32 "description": "ignores arrays",
33 "data": [],
34 "valid": true
35 },
36 {
37 "description": "ignores other non-objects",
38 "data": 12,
39 "valid": true
40 }
41 ]
42 },
43 {
44 "description":
45 "properties, patternProperties, additionalProperties interaction",
46 "schema": {
47 "properties": {
48 "foo": {"type": "array", "maxItems": 3},
49 "bar": {"type": "array"}
50 },
51 "patternProperties": {"f.o": {"minItems": 2}},
52 "additionalProperties": {"type": "integer"}
53 },
54 "tests": [
55 {
56 "description": "property validates property",
57 "data": {"foo": [1, 2]},
58 "valid": true
59 },
60 {
61 "description": "property invalidates property",
62 "data": {"foo": [1, 2, 3, 4]},
63 "valid": false
64 },
65 {
66 "description": "patternProperty invalidates property",
67 "data": {"foo": []},
68 "valid": false
69 },
70 {
71 "description": "patternProperty validates nonproperty",
72 "data": {"fxo": [1, 2]},
73 "valid": true
74 },
75 {
76 "description": "patternProperty invalidates nonproperty",
77 "data": {"fxo": []},
78 "valid": false
79 },
80 {
81 "description": "additionalProperty ignores property",
82 "data": {"bar": []},
83 "valid": true
84 },
85 {
86 "description": "additionalProperty validates others",
87 "data": {"quux": 3},
88 "valid": true
89 },
90 {
91 "description": "additionalProperty invalidates others",
92 "data": {"quux": "foo"},
93 "valid": false
94 }
95 ]
96 },
97 {
98 "description": "properties with boolean schema",
99 "schema": {
100 "properties": {
101 "foo": true,
102 "bar": false
103 }
104 },
105 "tests": [
106 {
107 "description": "no property present is valid",
108 "data": {},
109 "valid": true
110 },
111 {
112 "description": "only 'true' property present is valid",
113 "data": {"foo": 1},
114 "valid": true
115 },
116 {
117 "description": "only 'false' property present is invalid",
118 "data": {"bar": 2},
119 "valid": false
120 },
121 {
122 "description": "both properties present is invalid",
123 "data": {"foo": 1, "bar": 2},
124 "valid": false
125 }
126 ]
127 },
128 {
129 "description": "properties with escaped characters",
130 "schema": {
131 "properties": {
132 "foo\nbar": {"type": "number"},
133 "foo\"bar": {"type": "number"},
134 "foo\\bar": {"type": "number"},
135 "foo\rbar": {"type": "number"},
136 "foo\tbar": {"type": "number"},
137 "foo\fbar": {"type": "number"}
138 }
139 },
140 "tests": [
141 {
142 "description": "object with all numbers is valid",
143 "data": {
144 "foo\nbar": 1,
145 "foo\"bar": 1,
146 "foo\\bar": 1,
147 "foo\rbar": 1,
148 "foo\tbar": 1,
149 "foo\fbar": 1
150 },
151 "valid": true
152 },
153 {
154 "description": "object with strings is invalid",
155 "data": {
156 "foo\nbar": "1",
157 "foo\"bar": "1",
158 "foo\\bar": "1",
159 "foo\rbar": "1",
160 "foo\tbar": "1",
161 "foo\fbar": "1"
162 },
163 "valid": false
164 }
165 ]
166 },
167 {
168 "description": "properties with null valued instance properties",
169 "schema": {
170 "properties": {
171 "foo": {"type": "null"}
172 }
173 },
174 "tests": [
175 {
176 "description": "allows null values",
177 "data": {"foo": null},
178 "valid": true
179 }
180 ]
181 },
182 {
183 "description": "properties whose names are Javascript object property names",
184 "comment": "Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object.",
185 "schema": {
186 "properties": {
187 "__proto__": {"type": "number"},
188 "toString": {
189 "properties": { "length": { "type": "string" } }
190 },
191 "constructor": {"type": "number"}
192 }
193 },
194 "tests": [
195 {
196 "description": "ignores arrays",
197 "data": [],
198 "valid": true
199 },
200 {
201 "description": "ignores other non-objects",
202 "data": 12,
203 "valid": true
204 },
205 {
206 "description": "none of the properties mentioned",
207 "data": {},
208 "valid": true
209 },
210 {
211 "description": "__proto__ not valid",
212 "data": { "__proto__": "foo" },
213 "valid": false
214 },
215 {
216 "description": "toString not valid",
217 "data": { "toString": { "length": 37 } },
218 "valid": false
219 },
220 {
221 "description": "constructor not valid",
222 "data": { "constructor": { "length": 37 } },
223 "valid": false
224 },
225 {
226 "description": "all present and valid",
227 "data": {
228 "__proto__": 12,
229 "toString": { "length": "foo" },
230 "constructor": 37
231 },
232 "valid": true
233 }
234 ]
235 }
236 ]