cuelang.org/go@v0.13.0/encoding/jsonschema/testdata/external/tests/draft4/enum.json (about) 1 [ 2 { 3 "description": "simple enum validation", 4 "schema": { 5 "enum": [ 6 1, 7 2, 8 3 9 ] 10 }, 11 "tests": [ 12 { 13 "description": "one of the enum is valid", 14 "data": 1, 15 "valid": true 16 }, 17 { 18 "description": "something else is invalid", 19 "data": 4, 20 "valid": false 21 } 22 ] 23 }, 24 { 25 "description": "heterogeneous enum validation", 26 "schema": { 27 "enum": [ 28 6, 29 "foo", 30 [], 31 true, 32 { 33 "foo": 12 34 } 35 ] 36 }, 37 "tests": [ 38 { 39 "description": "one of the enum is valid", 40 "data": [], 41 "valid": true 42 }, 43 { 44 "description": "something else is invalid", 45 "data": null, 46 "valid": false 47 }, 48 { 49 "description": "objects are deep compared", 50 "data": { 51 "foo": false 52 }, 53 "valid": false 54 }, 55 { 56 "description": "valid object matches", 57 "data": { 58 "foo": 12 59 }, 60 "valid": true 61 }, 62 { 63 "description": "extra properties in object is invalid", 64 "data": { 65 "foo": 12, 66 "boo": 42 67 }, 68 "valid": false 69 } 70 ] 71 }, 72 { 73 "description": "heterogeneous enum-with-null validation", 74 "schema": { 75 "enum": [ 76 6, 77 null 78 ] 79 }, 80 "tests": [ 81 { 82 "description": "null is valid", 83 "data": null, 84 "valid": true 85 }, 86 { 87 "description": "number is valid", 88 "data": 6, 89 "valid": true 90 }, 91 { 92 "description": "something else is invalid", 93 "data": "test", 94 "valid": false 95 } 96 ] 97 }, 98 { 99 "description": "enums in properties", 100 "schema": { 101 "type": "object", 102 "properties": { 103 "foo": { 104 "enum": [ 105 "foo" 106 ] 107 }, 108 "bar": { 109 "enum": [ 110 "bar" 111 ] 112 } 113 }, 114 "required": [ 115 "bar" 116 ] 117 }, 118 "tests": [ 119 { 120 "description": "both properties are valid", 121 "data": { 122 "foo": "foo", 123 "bar": "bar" 124 }, 125 "valid": true 126 }, 127 { 128 "description": "wrong foo value", 129 "data": { 130 "foo": "foot", 131 "bar": "bar" 132 }, 133 "valid": false 134 }, 135 { 136 "description": "wrong bar value", 137 "data": { 138 "foo": "foo", 139 "bar": "bart" 140 }, 141 "valid": false 142 }, 143 { 144 "description": "missing optional property is valid", 145 "data": { 146 "bar": "bar" 147 }, 148 "valid": true 149 }, 150 { 151 "description": "missing required property is invalid", 152 "data": { 153 "foo": "foo" 154 }, 155 "valid": false 156 }, 157 { 158 "description": "missing all properties is invalid", 159 "data": {}, 160 "valid": false 161 } 162 ] 163 }, 164 { 165 "description": "enum with escaped characters", 166 "schema": { 167 "enum": [ 168 "foo\nbar", 169 "foo\rbar" 170 ] 171 }, 172 "tests": [ 173 { 174 "description": "member 1 is valid", 175 "data": "foo\nbar", 176 "valid": true 177 }, 178 { 179 "description": "member 2 is valid", 180 "data": "foo\rbar", 181 "valid": true 182 }, 183 { 184 "description": "another string is invalid", 185 "data": "abc", 186 "valid": false 187 } 188 ] 189 }, 190 { 191 "description": "enum with false does not match 0", 192 "schema": { 193 "enum": [ 194 false 195 ] 196 }, 197 "tests": [ 198 { 199 "description": "false is valid", 200 "data": false, 201 "valid": true 202 }, 203 { 204 "description": "integer zero is invalid", 205 "data": 0, 206 "valid": false 207 }, 208 { 209 "description": "float zero is invalid", 210 "data": 0.0, 211 "valid": false 212 } 213 ] 214 }, 215 { 216 "description": "enum with [false] does not match [0]", 217 "schema": { 218 "enum": [ 219 [ 220 false 221 ] 222 ] 223 }, 224 "tests": [ 225 { 226 "description": "[false] is valid", 227 "data": [ 228 false 229 ], 230 "valid": true 231 }, 232 { 233 "description": "[0] is invalid", 234 "data": [ 235 0 236 ], 237 "valid": false 238 }, 239 { 240 "description": "[0.0] is invalid", 241 "data": [ 242 0.0 243 ], 244 "valid": false 245 } 246 ] 247 }, 248 { 249 "description": "enum with true does not match 1", 250 "schema": { 251 "enum": [ 252 true 253 ] 254 }, 255 "tests": [ 256 { 257 "description": "true is valid", 258 "data": true, 259 "valid": true 260 }, 261 { 262 "description": "integer one is invalid", 263 "data": 1, 264 "valid": false 265 }, 266 { 267 "description": "float one is invalid", 268 "data": 1.0, 269 "valid": false 270 } 271 ] 272 }, 273 { 274 "description": "enum with [true] does not match [1]", 275 "schema": { 276 "enum": [ 277 [ 278 true 279 ] 280 ] 281 }, 282 "tests": [ 283 { 284 "description": "[true] is valid", 285 "data": [ 286 true 287 ], 288 "valid": true 289 }, 290 { 291 "description": "[1] is invalid", 292 "data": [ 293 1 294 ], 295 "valid": false 296 }, 297 { 298 "description": "[1.0] is invalid", 299 "data": [ 300 1.0 301 ], 302 "valid": false 303 } 304 ] 305 }, 306 { 307 "description": "enum with 0 does not match false", 308 "schema": { 309 "enum": [ 310 0 311 ] 312 }, 313 "tests": [ 314 { 315 "description": "false is invalid", 316 "data": false, 317 "valid": false 318 }, 319 { 320 "description": "integer zero is valid", 321 "data": 0, 322 "valid": true 323 }, 324 { 325 "description": "float zero is valid", 326 "data": 0.0, 327 "valid": true, 328 "skip": { 329 "v2": "conflicting values 0.0 and 0 (mismatched types float and int):\n generated.cue:2:1\n instance.json:1:1\n", 330 "v3": "conflicting values 0.0 and 0 (mismatched types float and int):\n generated.cue:2:1\n instance.json:1:1\n" 331 } 332 } 333 ] 334 }, 335 { 336 "description": "enum with [0] does not match [false]", 337 "schema": { 338 "enum": [ 339 [ 340 0 341 ] 342 ] 343 }, 344 "tests": [ 345 { 346 "description": "[false] is invalid", 347 "data": [ 348 false 349 ], 350 "valid": false 351 }, 352 { 353 "description": "[0] is valid", 354 "data": [ 355 0 356 ], 357 "valid": true 358 }, 359 { 360 "description": "[0.0] is valid", 361 "data": [ 362 0.0 363 ], 364 "valid": true, 365 "skip": { 366 "v2": "0: conflicting values 0.0 and 0 (mismatched types float and int):\n generated.cue:2:1\n generated.cue:2:2\n instance.json:1:2\n", 367 "v3": "0: conflicting values 0.0 and 0 (mismatched types float and int):\n generated.cue:2:2\n instance.json:1:2\n" 368 } 369 } 370 ] 371 }, 372 { 373 "description": "enum with 1 does not match true", 374 "schema": { 375 "enum": [ 376 1 377 ] 378 }, 379 "tests": [ 380 { 381 "description": "true is invalid", 382 "data": true, 383 "valid": false 384 }, 385 { 386 "description": "integer one is valid", 387 "data": 1, 388 "valid": true 389 }, 390 { 391 "description": "float one is valid", 392 "data": 1.0, 393 "valid": true, 394 "skip": { 395 "v2": "conflicting values 1.0 and 1 (mismatched types float and int):\n generated.cue:2:1\n instance.json:1:1\n", 396 "v3": "conflicting values 1.0 and 1 (mismatched types float and int):\n generated.cue:2:1\n instance.json:1:1\n" 397 } 398 } 399 ] 400 }, 401 { 402 "description": "enum with [1] does not match [true]", 403 "schema": { 404 "enum": [ 405 [ 406 1 407 ] 408 ] 409 }, 410 "tests": [ 411 { 412 "description": "[true] is invalid", 413 "data": [ 414 true 415 ], 416 "valid": false 417 }, 418 { 419 "description": "[1] is valid", 420 "data": [ 421 1 422 ], 423 "valid": true 424 }, 425 { 426 "description": "[1.0] is valid", 427 "data": [ 428 1.0 429 ], 430 "valid": true, 431 "skip": { 432 "v2": "0: conflicting values 1.0 and 1 (mismatched types float and int):\n generated.cue:2:1\n generated.cue:2:2\n instance.json:1:2\n", 433 "v3": "0: conflicting values 1.0 and 1 (mismatched types float and int):\n generated.cue:2:2\n instance.json:1:2\n" 434 } 435 } 436 ] 437 }, 438 { 439 "description": "nul characters in strings", 440 "schema": { 441 "enum": [ 442 "hello\u0000there" 443 ] 444 }, 445 "tests": [ 446 { 447 "description": "match string with nul", 448 "data": "hello\u0000there", 449 "valid": true 450 }, 451 { 452 "description": "do not match string lacking nul", 453 "data": "hellothere", 454 "valid": false 455 } 456 ] 457 } 458 ]