cuelang.org/go@v0.13.0/encoding/jsonschema/testdata/external/tests/draft4/properties.json (about) 1 [ 2 { 3 "description": "object properties validation", 4 "schema": { 5 "properties": { 6 "foo": { 7 "type": "integer" 8 }, 9 "bar": { 10 "type": "string" 11 } 12 } 13 }, 14 "tests": [ 15 { 16 "description": "both properties present and valid is valid", 17 "data": { 18 "foo": 1, 19 "bar": "baz" 20 }, 21 "valid": true 22 }, 23 { 24 "description": "one property invalid is invalid", 25 "data": { 26 "foo": 1, 27 "bar": {} 28 }, 29 "valid": false 30 }, 31 { 32 "description": "both properties invalid is invalid", 33 "data": { 34 "foo": [], 35 "bar": {} 36 }, 37 "valid": false 38 }, 39 { 40 "description": "doesn't invalidate other properties", 41 "data": { 42 "quux": [] 43 }, 44 "valid": true 45 }, 46 { 47 "description": "ignores arrays", 48 "data": [], 49 "valid": true 50 }, 51 { 52 "description": "ignores other non-objects", 53 "data": 12, 54 "valid": true 55 } 56 ] 57 }, 58 { 59 "description": "properties, patternProperties, additionalProperties interaction", 60 "schema": { 61 "properties": { 62 "foo": { 63 "type": "array", 64 "maxItems": 3 65 }, 66 "bar": { 67 "type": "array" 68 } 69 }, 70 "patternProperties": { 71 "f.o": { 72 "minItems": 2 73 } 74 }, 75 "additionalProperties": { 76 "type": "integer" 77 } 78 }, 79 "tests": [ 80 { 81 "description": "property validates property", 82 "data": { 83 "foo": [ 84 1, 85 2 86 ] 87 }, 88 "valid": true 89 }, 90 { 91 "description": "property invalidates property", 92 "data": { 93 "foo": [ 94 1, 95 2, 96 3, 97 4 98 ] 99 }, 100 "valid": false 101 }, 102 { 103 "description": "patternProperty invalidates property", 104 "data": { 105 "foo": [] 106 }, 107 "valid": false, 108 "skip": { 109 "v2": "unexpected success", 110 "v3": "unexpected success" 111 } 112 }, 113 { 114 "description": "patternProperty validates nonproperty", 115 "data": { 116 "fxo": [ 117 1, 118 2 119 ] 120 }, 121 "valid": true 122 }, 123 { 124 "description": "patternProperty invalidates nonproperty", 125 "data": { 126 "fxo": [] 127 }, 128 "valid": false 129 }, 130 { 131 "description": "additionalProperty ignores property", 132 "data": { 133 "bar": [] 134 }, 135 "valid": true 136 }, 137 { 138 "description": "additionalProperty validates others", 139 "data": { 140 "quux": 3 141 }, 142 "valid": true 143 }, 144 { 145 "description": "additionalProperty invalidates others", 146 "data": { 147 "quux": "foo" 148 }, 149 "valid": false 150 } 151 ] 152 }, 153 { 154 "description": "properties with escaped characters", 155 "schema": { 156 "properties": { 157 "foo\nbar": { 158 "type": "number" 159 }, 160 "foo\"bar": { 161 "type": "number" 162 }, 163 "foo\\bar": { 164 "type": "number" 165 }, 166 "foo\rbar": { 167 "type": "number" 168 }, 169 "foo\tbar": { 170 "type": "number" 171 }, 172 "foo\fbar": { 173 "type": "number" 174 } 175 } 176 }, 177 "tests": [ 178 { 179 "description": "object with all numbers is valid", 180 "data": { 181 "foo\nbar": 1, 182 "foo\"bar": 1, 183 "foo\\bar": 1, 184 "foo\rbar": 1, 185 "foo\tbar": 1, 186 "foo\fbar": 1 187 }, 188 "valid": true 189 }, 190 { 191 "description": "object with strings is invalid", 192 "data": { 193 "foo\nbar": "1", 194 "foo\"bar": "1", 195 "foo\\bar": "1", 196 "foo\rbar": "1", 197 "foo\tbar": "1", 198 "foo\fbar": "1" 199 }, 200 "valid": false 201 } 202 ] 203 }, 204 { 205 "description": "properties with null valued instance properties", 206 "schema": { 207 "properties": { 208 "foo": { 209 "type": "null" 210 } 211 } 212 }, 213 "tests": [ 214 { 215 "description": "allows null values", 216 "data": { 217 "foo": null 218 }, 219 "valid": true 220 } 221 ] 222 }, 223 { 224 "description": "properties whose names are Javascript object property names", 225 "comment": "Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object.", 226 "schema": { 227 "properties": { 228 "__proto__": { 229 "type": "number" 230 }, 231 "toString": { 232 "properties": { 233 "length": { 234 "type": "string" 235 } 236 } 237 }, 238 "constructor": { 239 "type": "number" 240 } 241 } 242 }, 243 "tests": [ 244 { 245 "description": "ignores arrays", 246 "data": [], 247 "valid": true 248 }, 249 { 250 "description": "ignores other non-objects", 251 "data": 12, 252 "valid": true 253 }, 254 { 255 "description": "none of the properties mentioned", 256 "data": {}, 257 "valid": true 258 }, 259 { 260 "description": "__proto__ not valid", 261 "data": { 262 "__proto__": "foo" 263 }, 264 "valid": false 265 }, 266 { 267 "description": "toString not valid", 268 "data": { 269 "toString": { 270 "length": 37 271 } 272 }, 273 "valid": false 274 }, 275 { 276 "description": "constructor not valid", 277 "data": { 278 "constructor": { 279 "length": 37 280 } 281 }, 282 "valid": false 283 }, 284 { 285 "description": "all present and valid", 286 "data": { 287 "__proto__": 12, 288 "toString": { 289 "length": "foo" 290 }, 291 "constructor": 37 292 }, 293 "valid": true 294 } 295 ] 296 } 297 ]