1[ 2 { 3 "description": "dependencies", 4 "schema": { 5 "dependencies": {"bar": ["foo"]} 6 }, 7 "tests": [ 8 { 9 "description": "neither", 10 "data": {}, 11 "valid": true 12 }, 13 { 14 "description": "nondependant", 15 "data": {"foo": 1}, 16 "valid": true 17 }, 18 { 19 "description": "with dependency", 20 "data": {"foo": 1, "bar": 2}, 21 "valid": true 22 }, 23 { 24 "description": "missing dependency", 25 "data": {"bar": 2}, 26 "valid": false 27 }, 28 { 29 "description": "ignores arrays", 30 "data": ["bar"], 31 "valid": true 32 }, 33 { 34 "description": "ignores strings", 35 "data": "foobar", 36 "valid": true 37 }, 38 { 39 "description": "ignores other non-objects", 40 "data": 12, 41 "valid": true 42 } 43 ] 44 }, 45 { 46 "description": "dependencies with empty array", 47 "schema": { 48 "dependencies": {"bar": []} 49 }, 50 "tests": [ 51 { 52 "description": "empty object", 53 "data": {}, 54 "valid": true 55 }, 56 { 57 "description": "object with one property", 58 "data": {"bar": 2}, 59 "valid": true 60 }, 61 { 62 "description": "non-object is valid", 63 "data": 1, 64 "valid": true 65 } 66 ] 67 }, 68 { 69 "description": "multiple dependencies", 70 "schema": { 71 "dependencies": {"quux": ["foo", "bar"]} 72 }, 73 "tests": [ 74 { 75 "description": "neither", 76 "data": {}, 77 "valid": true 78 }, 79 { 80 "description": "nondependants", 81 "data": {"foo": 1, "bar": 2}, 82 "valid": true 83 }, 84 { 85 "description": "with dependencies", 86 "data": {"foo": 1, "bar": 2, "quux": 3}, 87 "valid": true 88 }, 89 { 90 "description": "missing dependency", 91 "data": {"foo": 1, "quux": 2}, 92 "valid": false 93 }, 94 { 95 "description": "missing other dependency", 96 "data": {"bar": 1, "quux": 2}, 97 "valid": false 98 }, 99 { 100 "description": "missing both dependencies", 101 "data": {"quux": 1}, 102 "valid": false 103 } 104 ] 105 }, 106 { 107 "description": "multiple dependencies subschema", 108 "schema": { 109 "dependencies": { 110 "bar": { 111 "properties": { 112 "foo": {"type": "integer"}, 113 "bar": {"type": "integer"} 114 } 115 } 116 } 117 }, 118 "tests": [ 119 { 120 "description": "valid", 121 "data": {"foo": 1, "bar": 2}, 122 "valid": true 123 }, 124 { 125 "description": "no dependency", 126 "data": {"foo": "quux"}, 127 "valid": true 128 }, 129 { 130 "description": "wrong type", 131 "data": {"foo": "quux", "bar": 2}, 132 "valid": false 133 }, 134 { 135 "description": "wrong type other", 136 "data": {"foo": 2, "bar": "quux"}, 137 "valid": false 138 }, 139 { 140 "description": "wrong type both", 141 "data": {"foo": "quux", "bar": "quux"}, 142 "valid": false 143 } 144 ] 145 }, 146 { 147 "description": "dependencies with boolean subschemas", 148 "schema": { 149 "dependencies": { 150 "foo": true, 151 "bar": false 152 } 153 }, 154 "tests": [ 155 { 156 "description": "object with property having schema true is valid", 157 "data": {"foo": 1}, 158 "valid": true 159 }, 160 { 161 "description": "object with property having schema false is invalid", 162 "data": {"bar": 2}, 163 "valid": false 164 }, 165 { 166 "description": "object with both properties is invalid", 167 "data": {"foo": 1, "bar": 2}, 168 "valid": false 169 }, 170 { 171 "description": "empty object is valid", 172 "data": {}, 173 "valid": true 174 } 175 ] 176 }, 177 { 178 "description": "dependencies with escaped characters", 179 "schema": { 180 "dependencies": { 181 "foo\nbar": ["foo\rbar"], 182 "foo\tbar": { 183 "minProperties": 4 184 }, 185 "foo'bar": {"required": ["foo\"bar"]}, 186 "foo\"bar": ["foo'bar"] 187 } 188 }, 189 "tests": [ 190 { 191 "description": "valid object 1", 192 "data": { 193 "foo\nbar": 1, 194 "foo\rbar": 2 195 }, 196 "valid": true 197 }, 198 { 199 "description": "valid object 2", 200 "data": { 201 "foo\tbar": 1, 202 "a": 2, 203 "b": 3, 204 "c": 4 205 }, 206 "valid": true 207 }, 208 { 209 "description": "valid object 3", 210 "data": { 211 "foo'bar": 1, 212 "foo\"bar": 2 213 }, 214 "valid": true 215 }, 216 { 217 "description": "invalid object 1", 218 "data": { 219 "foo\nbar": 1, 220 "foo": 2 221 }, 222 "valid": false 223 }, 224 { 225 "description": "invalid object 2", 226 "data": { 227 "foo\tbar": 1, 228 "a": 2 229 }, 230 "valid": false 231 }, 232 { 233 "description": "invalid object 3", 234 "data": { 235 "foo'bar": 1 236 }, 237 "valid": false 238 }, 239 { 240 "description": "invalid object 4", 241 "data": { 242 "foo\"bar": 2 243 }, 244 "valid": false 245 } 246 ] 247 }, 248 { 249 "description": "dependent subschema incompatible with root", 250 "schema": { 251 "properties": { 252 "foo": {} 253 }, 254 "dependencies": { 255 "foo": { 256 "properties": { 257 "bar": {} 258 }, 259 "additionalProperties": false 260 } 261 } 262 }, 263 "tests": [ 264 { 265 "description": "matches root", 266 "data": {"foo": 1}, 267 "valid": false 268 }, 269 { 270 "description": "matches dependency", 271 "data": {"bar": 1}, 272 "valid": true 273 }, 274 { 275 "description": "matches both", 276 "data": {"foo": 1, "bar": 2}, 277 "valid": false 278 }, 279 { 280 "description": "no dependency", 281 "data": {"baz": 1}, 282 "valid": true 283 } 284 ] 285 } 286] 287