Debian Codegraph @

share/tests/v1/required.json

raw
1 [
2 {
3 "description": "required validation",
4 "schema": {
5 "$schema": "https://json-schema.org/v1",
6 "properties": {
7 "foo": {},
8 "bar": {}
9 },
10 "required": ["foo"]
11 },
12 "tests": [
13 {
14 "description": "present required property is valid",
15 "data": {"foo": 1},
16 "valid": true
17 },
18 {
19 "description": "non-present required property is invalid",
20 "data": {"bar": 1},
21 "valid": false
22 },
23 {
24 "description": "ignores arrays",
25 "data": [],
26 "valid": true
27 },
28 {
29 "description": "ignores strings",
30 "data": "",
31 "valid": true
32 },
33 {
34 "description": "ignores other non-objects",
35 "data": 12,
36 "valid": true
37 },
38 {
39 "description": "ignores null",
40 "data": null,
41 "valid": true
42 },
43 {
44 "description": "ignores boolean",
45 "data": true,
46 "valid": true
47 }
48 ]
49 },
50 {
51 "description": "required default validation",
52 "schema": {
53 "$schema": "https://json-schema.org/v1",
54 "properties": {
55 "foo": {}
56 }
57 },
58 "tests": [
59 {
60 "description": "not required by default",
61 "data": {},
62 "valid": true
63 }
64 ]
65 },
66 {
67 "description": "required with empty array",
68 "schema": {
69 "$schema": "https://json-schema.org/v1",
70 "properties": {
71 "foo": {}
72 },
73 "required": []
74 },
75 "tests": [
76 {
77 "description": "property not required",
78 "data": {},
79 "valid": true
80 }
81 ]
82 },
83 {
84 "description": "required with escaped characters",
85 "schema": {
86 "$schema": "https://json-schema.org/v1",
87 "required": [
88 "foo\nbar",
89 "foo\"bar",
90 "foo\\bar",
91 "foo\rbar",
92 "foo\tbar",
93 "foo\fbar"
94 ]
95 },
96 "tests": [
97 {
98 "description": "object with all properties present is valid",
99 "data": {
100 "foo\nbar": 1,
101 "foo\"bar": 1,
102 "foo\\bar": 1,
103 "foo\rbar": 1,
104 "foo\tbar": 1,
105 "foo\fbar": 1
106 },
107 "valid": true
108 },
109 {
110 "description": "object with some properties missing is invalid",
111 "data": {
112 "foo\nbar": "1",
113 "foo\"bar": "1"
114 },
115 "valid": false
116 }
117 ]
118 },
119 {
120 "description": "required properties whose names are Javascript object property names",
121 "comment": "Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object.",
122 "schema": {
123 "$schema": "https://json-schema.org/v1",
124 "required": ["__proto__", "toString", "constructor"]
125 },
126 "tests": [
127 {
128 "description": "ignores arrays",
129 "data": [],
130 "valid": true
131 },
132 {
133 "description": "ignores other non-objects",
134 "data": 12,
135 "valid": true
136 },
137 {
138 "description": "none of the properties mentioned",
139 "data": {},
140 "valid": false
141 },
142 {
143 "description": "__proto__ present",
144 "data": { "__proto__": "foo" },
145 "valid": false
146 },
147 {
148 "description": "toString present",
149 "data": { "toString": { "length": 37 } },
150 "valid": false
151 },
152 {
153 "description": "constructor present",
154 "data": { "constructor": { "length": 37 } },
155 "valid": false
156 },
157 {
158 "description": "all present",
159 "data": {
160 "__proto__": 12,
161 "toString": { "length": "foo" },
162 "constructor": 37
163 },
164 "valid": true
165 }
166 ]
167 }
168 ]