cuelang.org/go@v0.13.0/encoding/jsonschema/testdata/external/tests/draft2020-12/uniqueItems.json (about) 1 [ 2 { 3 "description": "uniqueItems validation", 4 "schema": { 5 "$schema": "https://json-schema.org/draft/2020-12/schema", 6 "uniqueItems": true 7 }, 8 "tests": [ 9 { 10 "description": "unique array of integers is valid", 11 "data": [ 12 1, 13 2 14 ], 15 "valid": true 16 }, 17 { 18 "description": "non-unique array of integers is invalid", 19 "data": [ 20 1, 21 1 22 ], 23 "valid": false 24 }, 25 { 26 "description": "non-unique array of more than two integers is invalid", 27 "data": [ 28 1, 29 2, 30 1 31 ], 32 "valid": false 33 }, 34 { 35 "description": "numbers are unique if mathematically unequal", 36 "data": [ 37 1.0, 38 1.00, 39 1 40 ], 41 "valid": false 42 }, 43 { 44 "description": "false is not equal to zero", 45 "data": [ 46 0, 47 false 48 ], 49 "valid": true 50 }, 51 { 52 "description": "true is not equal to one", 53 "data": [ 54 1, 55 true 56 ], 57 "valid": true 58 }, 59 { 60 "description": "unique array of strings is valid", 61 "data": [ 62 "foo", 63 "bar", 64 "baz" 65 ], 66 "valid": true 67 }, 68 { 69 "description": "non-unique array of strings is invalid", 70 "data": [ 71 "foo", 72 "bar", 73 "foo" 74 ], 75 "valid": false 76 }, 77 { 78 "description": "unique array of objects is valid", 79 "data": [ 80 { 81 "foo": "bar" 82 }, 83 { 84 "foo": "baz" 85 } 86 ], 87 "valid": true 88 }, 89 { 90 "description": "non-unique array of objects is invalid", 91 "data": [ 92 { 93 "foo": "bar" 94 }, 95 { 96 "foo": "bar" 97 } 98 ], 99 "valid": false 100 }, 101 { 102 "description": "property order of array of objects is ignored", 103 "data": [ 104 { 105 "foo": "bar", 106 "bar": "foo" 107 }, 108 { 109 "bar": "foo", 110 "foo": "bar" 111 } 112 ], 113 "valid": false 114 }, 115 { 116 "description": "unique array of nested objects is valid", 117 "data": [ 118 { 119 "foo": { 120 "bar": { 121 "baz": true 122 } 123 } 124 }, 125 { 126 "foo": { 127 "bar": { 128 "baz": false 129 } 130 } 131 } 132 ], 133 "valid": true 134 }, 135 { 136 "description": "non-unique array of nested objects is invalid", 137 "data": [ 138 { 139 "foo": { 140 "bar": { 141 "baz": true 142 } 143 } 144 }, 145 { 146 "foo": { 147 "bar": { 148 "baz": true 149 } 150 } 151 } 152 ], 153 "valid": false 154 }, 155 { 156 "description": "unique array of arrays is valid", 157 "data": [ 158 [ 159 "foo" 160 ], 161 [ 162 "bar" 163 ] 164 ], 165 "valid": true 166 }, 167 { 168 "description": "non-unique array of arrays is invalid", 169 "data": [ 170 [ 171 "foo" 172 ], 173 [ 174 "foo" 175 ] 176 ], 177 "valid": false 178 }, 179 { 180 "description": "non-unique array of more than two arrays is invalid", 181 "data": [ 182 [ 183 "foo" 184 ], 185 [ 186 "bar" 187 ], 188 [ 189 "foo" 190 ] 191 ], 192 "valid": false 193 }, 194 { 195 "description": "1 and true are unique", 196 "data": [ 197 1, 198 true 199 ], 200 "valid": true 201 }, 202 { 203 "description": "0 and false are unique", 204 "data": [ 205 0, 206 false 207 ], 208 "valid": true 209 }, 210 { 211 "description": "[1] and [true] are unique", 212 "data": [ 213 [ 214 1 215 ], 216 [ 217 true 218 ] 219 ], 220 "valid": true 221 }, 222 { 223 "description": "[0] and [false] are unique", 224 "data": [ 225 [ 226 0 227 ], 228 [ 229 false 230 ] 231 ], 232 "valid": true 233 }, 234 { 235 "description": "nested [1] and [true] are unique", 236 "data": [ 237 [ 238 [ 239 1 240 ], 241 "foo" 242 ], 243 [ 244 [ 245 true 246 ], 247 "foo" 248 ] 249 ], 250 "valid": true 251 }, 252 { 253 "description": "nested [0] and [false] are unique", 254 "data": [ 255 [ 256 [ 257 0 258 ], 259 "foo" 260 ], 261 [ 262 [ 263 false 264 ], 265 "foo" 266 ] 267 ], 268 "valid": true 269 }, 270 { 271 "description": "unique heterogeneous types are valid", 272 "data": [ 273 {}, 274 [ 275 1 276 ], 277 true, 278 null, 279 1, 280 "{}" 281 ], 282 "valid": true 283 }, 284 { 285 "description": "non-unique heterogeneous types are invalid", 286 "data": [ 287 {}, 288 [ 289 1 290 ], 291 true, 292 null, 293 {}, 294 1 295 ], 296 "valid": false 297 }, 298 { 299 "description": "different objects are unique", 300 "data": [ 301 { 302 "a": 1, 303 "b": 2 304 }, 305 { 306 "a": 2, 307 "b": 1 308 } 309 ], 310 "valid": true 311 }, 312 { 313 "description": "objects are non-unique despite key order", 314 "data": [ 315 { 316 "a": 1, 317 "b": 2 318 }, 319 { 320 "b": 2, 321 "a": 1 322 } 323 ], 324 "valid": false 325 }, 326 { 327 "description": "{\"a\": false} and {\"a\": 0} are unique", 328 "data": [ 329 { 330 "a": false 331 }, 332 { 333 "a": 0 334 } 335 ], 336 "valid": true 337 }, 338 { 339 "description": "{\"a\": true} and {\"a\": 1} are unique", 340 "data": [ 341 { 342 "a": true 343 }, 344 { 345 "a": 1 346 } 347 ], 348 "valid": true 349 } 350 ] 351 }, 352 { 353 "description": "uniqueItems with an array of items", 354 "schema": { 355 "$schema": "https://json-schema.org/draft/2020-12/schema", 356 "prefixItems": [ 357 { 358 "type": "boolean" 359 }, 360 { 361 "type": "boolean" 362 } 363 ], 364 "uniqueItems": true 365 }, 366 "tests": [ 367 { 368 "description": "[false, true] from items array is valid", 369 "data": [ 370 false, 371 true 372 ], 373 "valid": true 374 }, 375 { 376 "description": "[true, false] from items array is valid", 377 "data": [ 378 true, 379 false 380 ], 381 "valid": true 382 }, 383 { 384 "description": "[false, false] from items array is not valid", 385 "data": [ 386 false, 387 false 388 ], 389 "valid": false 390 }, 391 { 392 "description": "[true, true] from items array is not valid", 393 "data": [ 394 true, 395 true 396 ], 397 "valid": false 398 }, 399 { 400 "description": "unique array extended from [false, true] is valid", 401 "data": [ 402 false, 403 true, 404 "foo", 405 "bar" 406 ], 407 "valid": true 408 }, 409 { 410 "description": "unique array extended from [true, false] is valid", 411 "data": [ 412 true, 413 false, 414 "foo", 415 "bar" 416 ], 417 "valid": true 418 }, 419 { 420 "description": "non-unique array extended from [false, true] is not valid", 421 "data": [ 422 false, 423 true, 424 "foo", 425 "foo" 426 ], 427 "valid": false 428 }, 429 { 430 "description": "non-unique array extended from [true, false] is not valid", 431 "data": [ 432 true, 433 false, 434 "foo", 435 "foo" 436 ], 437 "valid": false 438 } 439 ] 440 }, 441 { 442 "description": "uniqueItems with an array of items and additionalItems=false", 443 "schema": { 444 "$schema": "https://json-schema.org/draft/2020-12/schema", 445 "prefixItems": [ 446 { 447 "type": "boolean" 448 }, 449 { 450 "type": "boolean" 451 } 452 ], 453 "uniqueItems": true, 454 "items": false 455 }, 456 "tests": [ 457 { 458 "description": "[false, true] from items array is valid", 459 "data": [ 460 false, 461 true 462 ], 463 "valid": true, 464 "skip": { 465 "v2": "7 errors in empty disjunction:\nconflicting values [false,true] and {...} (mismatched types list and struct):\n generated.cue:5:1\n generated.cue:5:85\n instance.json:1:1\nconflicting values bool and [false,true] (mismatched types bool and list):\n generated.cue:5:8\n instance.json:1:1\nconflicting values null and [false,true] (mismatched types null and list):\n generated.cue:5:1\n instance.json:1:1\nconflicting values number and [false,true] (mismatched types number and list):\n generated.cue:5:15\n instance.json:1:1\nconflicting values string and [false,true] (mismatched types string and list):\n generated.cue:5:24\n instance.json:1:1\ninvalid value [_|_(explicit error (_|_ literal) in source),_|_(explicit error (_|_ literal) in source)] (does not satisfy list.UniqueItems): equal values at position 0 and 1:\n generated.cue:5:33\n generated.cue:1:1\n instance.json:1:1\nexplicit error (_|_ literal) in source:\n generated.cue:5:78\n", 466 "v3": "6 errors in empty disjunction:\nconflicting values [false,true] and bool (mismatched types list and bool):\n generated.cue:5:8\n instance.json:1:1\nconflicting values [false,true] and null (mismatched types list and null):\n generated.cue:5:1\n instance.json:1:1\nconflicting values [false,true] and number (mismatched types list and number):\n generated.cue:5:15\n instance.json:1:1\nconflicting values [false,true] and string (mismatched types list and string):\n generated.cue:5:24\n instance.json:1:1\nconflicting values [false,true] and {...} (mismatched types list and struct):\n generated.cue:5:85\n instance.json:1:1\nexplicit error (_|_ literal) in source:\n generated.cue:5:78\n" 467 } 468 }, 469 { 470 "description": "[true, false] from items array is valid", 471 "data": [ 472 true, 473 false 474 ], 475 "valid": true, 476 "skip": { 477 "v2": "7 errors in empty disjunction:\nconflicting values [true,false] and {...} (mismatched types list and struct):\n generated.cue:5:1\n generated.cue:5:85\n instance.json:1:1\nconflicting values bool and [true,false] (mismatched types bool and list):\n generated.cue:5:8\n instance.json:1:1\nconflicting values null and [true,false] (mismatched types null and list):\n generated.cue:5:1\n instance.json:1:1\nconflicting values number and [true,false] (mismatched types number and list):\n generated.cue:5:15\n instance.json:1:1\nconflicting values string and [true,false] (mismatched types string and list):\n generated.cue:5:24\n instance.json:1:1\ninvalid value [_|_(explicit error (_|_ literal) in source),_|_(explicit error (_|_ literal) in source)] (does not satisfy list.UniqueItems): equal values at position 0 and 1:\n generated.cue:5:33\n generated.cue:1:1\n instance.json:1:1\nexplicit error (_|_ literal) in source:\n generated.cue:5:78\n", 478 "v3": "6 errors in empty disjunction:\nconflicting values [true,false] and bool (mismatched types list and bool):\n generated.cue:5:8\n instance.json:1:1\nconflicting values [true,false] and null (mismatched types list and null):\n generated.cue:5:1\n instance.json:1:1\nconflicting values [true,false] and number (mismatched types list and number):\n generated.cue:5:15\n instance.json:1:1\nconflicting values [true,false] and string (mismatched types list and string):\n generated.cue:5:24\n instance.json:1:1\nconflicting values [true,false] and {...} (mismatched types list and struct):\n generated.cue:5:85\n instance.json:1:1\nexplicit error (_|_ literal) in source:\n generated.cue:5:78\n" 479 } 480 }, 481 { 482 "description": "[false, false] from items array is not valid", 483 "data": [ 484 false, 485 false 486 ], 487 "valid": false 488 }, 489 { 490 "description": "[true, true] from items array is not valid", 491 "data": [ 492 true, 493 true 494 ], 495 "valid": false 496 }, 497 { 498 "description": "extra items are invalid even if unique", 499 "data": [ 500 false, 501 true, 502 null 503 ], 504 "valid": false 505 } 506 ] 507 }, 508 { 509 "description": "uniqueItems=false validation", 510 "schema": { 511 "$schema": "https://json-schema.org/draft/2020-12/schema", 512 "uniqueItems": false 513 }, 514 "tests": [ 515 { 516 "description": "unique array of integers is valid", 517 "data": [ 518 1, 519 2 520 ], 521 "valid": true 522 }, 523 { 524 "description": "non-unique array of integers is valid", 525 "data": [ 526 1, 527 1 528 ], 529 "valid": true 530 }, 531 { 532 "description": "numbers are unique if mathematically unequal", 533 "data": [ 534 1.0, 535 1.00, 536 1 537 ], 538 "valid": true 539 }, 540 { 541 "description": "false is not equal to zero", 542 "data": [ 543 0, 544 false 545 ], 546 "valid": true 547 }, 548 { 549 "description": "true is not equal to one", 550 "data": [ 551 1, 552 true 553 ], 554 "valid": true 555 }, 556 { 557 "description": "unique array of objects is valid", 558 "data": [ 559 { 560 "foo": "bar" 561 }, 562 { 563 "foo": "baz" 564 } 565 ], 566 "valid": true 567 }, 568 { 569 "description": "non-unique array of objects is valid", 570 "data": [ 571 { 572 "foo": "bar" 573 }, 574 { 575 "foo": "bar" 576 } 577 ], 578 "valid": true 579 }, 580 { 581 "description": "unique array of nested objects is valid", 582 "data": [ 583 { 584 "foo": { 585 "bar": { 586 "baz": true 587 } 588 } 589 }, 590 { 591 "foo": { 592 "bar": { 593 "baz": false 594 } 595 } 596 } 597 ], 598 "valid": true 599 }, 600 { 601 "description": "non-unique array of nested objects is valid", 602 "data": [ 603 { 604 "foo": { 605 "bar": { 606 "baz": true 607 } 608 } 609 }, 610 { 611 "foo": { 612 "bar": { 613 "baz": true 614 } 615 } 616 } 617 ], 618 "valid": true 619 }, 620 { 621 "description": "unique array of arrays is valid", 622 "data": [ 623 [ 624 "foo" 625 ], 626 [ 627 "bar" 628 ] 629 ], 630 "valid": true 631 }, 632 { 633 "description": "non-unique array of arrays is valid", 634 "data": [ 635 [ 636 "foo" 637 ], 638 [ 639 "foo" 640 ] 641 ], 642 "valid": true 643 }, 644 { 645 "description": "1 and true are unique", 646 "data": [ 647 1, 648 true 649 ], 650 "valid": true 651 }, 652 { 653 "description": "0 and false are unique", 654 "data": [ 655 0, 656 false 657 ], 658 "valid": true 659 }, 660 { 661 "description": "unique heterogeneous types are valid", 662 "data": [ 663 {}, 664 [ 665 1 666 ], 667 true, 668 null, 669 1 670 ], 671 "valid": true 672 }, 673 { 674 "description": "non-unique heterogeneous types are valid", 675 "data": [ 676 {}, 677 [ 678 1 679 ], 680 true, 681 null, 682 {}, 683 1 684 ], 685 "valid": true 686 } 687 ] 688 }, 689 { 690 "description": "uniqueItems=false with an array of items", 691 "schema": { 692 "$schema": "https://json-schema.org/draft/2020-12/schema", 693 "prefixItems": [ 694 { 695 "type": "boolean" 696 }, 697 { 698 "type": "boolean" 699 } 700 ], 701 "uniqueItems": false 702 }, 703 "tests": [ 704 { 705 "description": "[false, true] from items array is valid", 706 "data": [ 707 false, 708 true 709 ], 710 "valid": true 711 }, 712 { 713 "description": "[true, false] from items array is valid", 714 "data": [ 715 true, 716 false 717 ], 718 "valid": true 719 }, 720 { 721 "description": "[false, false] from items array is valid", 722 "data": [ 723 false, 724 false 725 ], 726 "valid": true 727 }, 728 { 729 "description": "[true, true] from items array is valid", 730 "data": [ 731 true, 732 true 733 ], 734 "valid": true 735 }, 736 { 737 "description": "unique array extended from [false, true] is valid", 738 "data": [ 739 false, 740 true, 741 "foo", 742 "bar" 743 ], 744 "valid": true 745 }, 746 { 747 "description": "unique array extended from [true, false] is valid", 748 "data": [ 749 true, 750 false, 751 "foo", 752 "bar" 753 ], 754 "valid": true 755 }, 756 { 757 "description": "non-unique array extended from [false, true] is valid", 758 "data": [ 759 false, 760 true, 761 "foo", 762 "foo" 763 ], 764 "valid": true 765 }, 766 { 767 "description": "non-unique array extended from [true, false] is valid", 768 "data": [ 769 true, 770 false, 771 "foo", 772 "foo" 773 ], 774 "valid": true 775 } 776 ] 777 }, 778 { 779 "description": "uniqueItems=false with an array of items and additionalItems=false", 780 "schema": { 781 "$schema": "https://json-schema.org/draft/2020-12/schema", 782 "prefixItems": [ 783 { 784 "type": "boolean" 785 }, 786 { 787 "type": "boolean" 788 } 789 ], 790 "uniqueItems": false, 791 "items": false 792 }, 793 "tests": [ 794 { 795 "description": "[false, true] from items array is valid", 796 "data": [ 797 false, 798 true 799 ], 800 "valid": true, 801 "skip": { 802 "v2": "6 errors in empty disjunction:\nconflicting values [false,true] and {...} (mismatched types list and struct):\n generated.cue:3:1\n generated.cue:3:64\n instance.json:1:1\nconflicting values bool and [false,true] (mismatched types bool and list):\n generated.cue:3:8\n instance.json:1:1\nconflicting values null and [false,true] (mismatched types null and list):\n generated.cue:3:1\n instance.json:1:1\nconflicting values number and [false,true] (mismatched types number and list):\n generated.cue:3:15\n instance.json:1:1\nconflicting values string and [false,true] (mismatched types string and list):\n generated.cue:3:24\n instance.json:1:1\nexplicit error (_|_ literal) in source:\n generated.cue:3:57\n", 803 "v3": "6 errors in empty disjunction:\nconflicting values [false,true] and bool (mismatched types list and bool):\n generated.cue:3:8\n instance.json:1:1\nconflicting values [false,true] and null (mismatched types list and null):\n generated.cue:3:1\n instance.json:1:1\nconflicting values [false,true] and number (mismatched types list and number):\n generated.cue:3:15\n instance.json:1:1\nconflicting values [false,true] and string (mismatched types list and string):\n generated.cue:3:24\n instance.json:1:1\nconflicting values [false,true] and {...} (mismatched types list and struct):\n generated.cue:3:64\n instance.json:1:1\nexplicit error (_|_ literal) in source:\n generated.cue:3:57\n" 804 } 805 }, 806 { 807 "description": "[true, false] from items array is valid", 808 "data": [ 809 true, 810 false 811 ], 812 "valid": true, 813 "skip": { 814 "v2": "6 errors in empty disjunction:\nconflicting values [true,false] and {...} (mismatched types list and struct):\n generated.cue:3:1\n generated.cue:3:64\n instance.json:1:1\nconflicting values bool and [true,false] (mismatched types bool and list):\n generated.cue:3:8\n instance.json:1:1\nconflicting values null and [true,false] (mismatched types null and list):\n generated.cue:3:1\n instance.json:1:1\nconflicting values number and [true,false] (mismatched types number and list):\n generated.cue:3:15\n instance.json:1:1\nconflicting values string and [true,false] (mismatched types string and list):\n generated.cue:3:24\n instance.json:1:1\nexplicit error (_|_ literal) in source:\n generated.cue:3:57\n", 815 "v3": "6 errors in empty disjunction:\nconflicting values [true,false] and bool (mismatched types list and bool):\n generated.cue:3:8\n instance.json:1:1\nconflicting values [true,false] and null (mismatched types list and null):\n generated.cue:3:1\n instance.json:1:1\nconflicting values [true,false] and number (mismatched types list and number):\n generated.cue:3:15\n instance.json:1:1\nconflicting values [true,false] and string (mismatched types list and string):\n generated.cue:3:24\n instance.json:1:1\nconflicting values [true,false] and {...} (mismatched types list and struct):\n generated.cue:3:64\n instance.json:1:1\nexplicit error (_|_ literal) in source:\n generated.cue:3:57\n" 816 } 817 }, 818 { 819 "description": "[false, false] from items array is valid", 820 "data": [ 821 false, 822 false 823 ], 824 "valid": true, 825 "skip": { 826 "v2": "6 errors in empty disjunction:\nconflicting values [false,false] and {...} (mismatched types list and struct):\n generated.cue:3:1\n generated.cue:3:64\n instance.json:1:1\nconflicting values bool and [false,false] (mismatched types bool and list):\n generated.cue:3:8\n instance.json:1:1\nconflicting values null and [false,false] (mismatched types null and list):\n generated.cue:3:1\n instance.json:1:1\nconflicting values number and [false,false] (mismatched types number and list):\n generated.cue:3:15\n instance.json:1:1\nconflicting values string and [false,false] (mismatched types string and list):\n generated.cue:3:24\n instance.json:1:1\nexplicit error (_|_ literal) in source:\n generated.cue:3:57\n", 827 "v3": "6 errors in empty disjunction:\nconflicting values [false,false] and bool (mismatched types list and bool):\n generated.cue:3:8\n instance.json:1:1\nconflicting values [false,false] and null (mismatched types list and null):\n generated.cue:3:1\n instance.json:1:1\nconflicting values [false,false] and number (mismatched types list and number):\n generated.cue:3:15\n instance.json:1:1\nconflicting values [false,false] and string (mismatched types list and string):\n generated.cue:3:24\n instance.json:1:1\nconflicting values [false,false] and {...} (mismatched types list and struct):\n generated.cue:3:64\n instance.json:1:1\nexplicit error (_|_ literal) in source:\n generated.cue:3:57\n" 828 } 829 }, 830 { 831 "description": "[true, true] from items array is valid", 832 "data": [ 833 true, 834 true 835 ], 836 "valid": true, 837 "skip": { 838 "v2": "6 errors in empty disjunction:\nconflicting values [true,true] and {...} (mismatched types list and struct):\n generated.cue:3:1\n generated.cue:3:64\n instance.json:1:1\nconflicting values bool and [true,true] (mismatched types bool and list):\n generated.cue:3:8\n instance.json:1:1\nconflicting values null and [true,true] (mismatched types null and list):\n generated.cue:3:1\n instance.json:1:1\nconflicting values number and [true,true] (mismatched types number and list):\n generated.cue:3:15\n instance.json:1:1\nconflicting values string and [true,true] (mismatched types string and list):\n generated.cue:3:24\n instance.json:1:1\nexplicit error (_|_ literal) in source:\n generated.cue:3:57\n", 839 "v3": "6 errors in empty disjunction:\nconflicting values [true,true] and bool (mismatched types list and bool):\n generated.cue:3:8\n instance.json:1:1\nconflicting values [true,true] and null (mismatched types list and null):\n generated.cue:3:1\n instance.json:1:1\nconflicting values [true,true] and number (mismatched types list and number):\n generated.cue:3:15\n instance.json:1:1\nconflicting values [true,true] and string (mismatched types list and string):\n generated.cue:3:24\n instance.json:1:1\nconflicting values [true,true] and {...} (mismatched types list and struct):\n generated.cue:3:64\n instance.json:1:1\nexplicit error (_|_ literal) in source:\n generated.cue:3:57\n" 840 } 841 }, 842 { 843 "description": "extra items are invalid even if unique", 844 "data": [ 845 false, 846 true, 847 null 848 ], 849 "valid": false 850 } 851 ] 852 } 853 ]