Debian Codegraph @

share/tests/draft6/required.json

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