cuelang.org/go@v0.13.0/encoding/jsonschema/testdata/external/tests/draft6/additionalItems.json (about)

     1  [
     2  	{
     3  		"description": "additionalItems as schema",
     4  		"schema": {
     5  			"items": [
     6  				{}
     7  			],
     8  			"additionalItems": {
     9  				"type": "integer"
    10  			}
    11  		},
    12  		"tests": [
    13  			{
    14  				"description": "additional items match schema",
    15  				"data": [
    16  					null,
    17  					2,
    18  					3,
    19  					4
    20  				],
    21  				"valid": true
    22  			},
    23  			{
    24  				"description": "additional items do not match schema",
    25  				"data": [
    26  					null,
    27  					2,
    28  					3,
    29  					"foo"
    30  				],
    31  				"valid": false
    32  			}
    33  		]
    34  	},
    35  	{
    36  		"description": "when items is schema, additionalItems does nothing",
    37  		"schema": {
    38  			"items": {
    39  				"type": "integer"
    40  			},
    41  			"additionalItems": {
    42  				"type": "string"
    43  			}
    44  		},
    45  		"tests": [
    46  			{
    47  				"description": "valid with a array of type integers",
    48  				"data": [
    49  					1,
    50  					2,
    51  					3
    52  				],
    53  				"valid": true
    54  			},
    55  			{
    56  				"description": "invalid with a array of mixed types",
    57  				"data": [
    58  					1,
    59  					"2",
    60  					"3"
    61  				],
    62  				"valid": false
    63  			}
    64  		]
    65  	},
    66  	{
    67  		"description": "when items is schema, boolean additionalItems does nothing",
    68  		"schema": {
    69  			"items": {},
    70  			"additionalItems": false
    71  		},
    72  		"tests": [
    73  			{
    74  				"description": "all items match schema",
    75  				"data": [
    76  					1,
    77  					2,
    78  					3,
    79  					4,
    80  					5
    81  				],
    82  				"valid": true
    83  			}
    84  		]
    85  	},
    86  	{
    87  		"description": "array of items with no additionalItems permitted",
    88  		"schema": {
    89  			"items": [
    90  				{},
    91  				{},
    92  				{}
    93  			],
    94  			"additionalItems": false
    95  		},
    96  		"tests": [
    97  			{
    98  				"description": "empty array",
    99  				"data": [],
   100  				"valid": true,
   101  				"skip": {
   102  					"v2": "5 errors in empty disjunction:\nconflicting values [] and {...} (mismatched types list and struct):\n    generated.cue:2:1\n    generated.cue:2:45\n    instance.json:1:1\nconflicting values bool and [] (mismatched types bool and list):\n    generated.cue:2:8\n    instance.json:1:1\nconflicting values null and [] (mismatched types null and list):\n    generated.cue:2:1\n    instance.json:1:1\nconflicting values number and [] (mismatched types number and list):\n    generated.cue:2:15\n    instance.json:1:1\nconflicting values string and [] (mismatched types string and list):\n    generated.cue:2:24\n    instance.json:1:1\n",
   103  					"v3": "6 errors in empty disjunction:\nconflicting values [] and bool (mismatched types list and bool):\n    generated.cue:2:8\n    instance.json:1:1\nconflicting values [] and null (mismatched types list and null):\n    generated.cue:2:1\n    instance.json:1:1\nconflicting values [] and number (mismatched types list and number):\n    generated.cue:2:15\n    instance.json:1:1\nconflicting values [] and string (mismatched types list and string):\n    generated.cue:2:24\n    instance.json:1:1\nconflicting values [] and {...} (mismatched types list and struct):\n    generated.cue:2:45\n    instance.json:1:1\nincompatible list lengths (0 and 3):\n    generated.cue:2:33\n"
   104  				}
   105  			},
   106  			{
   107  				"description": "fewer number of items present (1)",
   108  				"data": [
   109  					1
   110  				],
   111  				"valid": true,
   112  				"skip": {
   113  					"v2": "5 errors in empty disjunction:\nconflicting values [1] and {...} (mismatched types list and struct):\n    generated.cue:2:1\n    generated.cue:2:45\n    instance.json:1:1\nconflicting values bool and [1] (mismatched types bool and list):\n    generated.cue:2:8\n    instance.json:1:1\nconflicting values null and [1] (mismatched types null and list):\n    generated.cue:2:1\n    instance.json:1:1\nconflicting values number and [1] (mismatched types number and list):\n    generated.cue:2:15\n    instance.json:1:1\nconflicting values string and [1] (mismatched types string and list):\n    generated.cue:2:24\n    instance.json:1:1\n",
   114  					"v3": "6 errors in empty disjunction:\nconflicting values [1] and bool (mismatched types list and bool):\n    generated.cue:2:8\n    instance.json:1:1\nconflicting values [1] and null (mismatched types list and null):\n    generated.cue:2:1\n    instance.json:1:1\nconflicting values [1] and number (mismatched types list and number):\n    generated.cue:2:15\n    instance.json:1:1\nconflicting values [1] and string (mismatched types list and string):\n    generated.cue:2:24\n    instance.json:1:1\nconflicting values [1] and {...} (mismatched types list and struct):\n    generated.cue:2:45\n    instance.json:1:1\nincompatible list lengths (1 and 3):\n    generated.cue:2:33\n"
   115  				}
   116  			},
   117  			{
   118  				"description": "fewer number of items present (2)",
   119  				"data": [
   120  					1,
   121  					2
   122  				],
   123  				"valid": true,
   124  				"skip": {
   125  					"v2": "5 errors in empty disjunction:\nconflicting values [1,2] and {...} (mismatched types list and struct):\n    generated.cue:2:1\n    generated.cue:2:45\n    instance.json:1:1\nconflicting values bool and [1,2] (mismatched types bool and list):\n    generated.cue:2:8\n    instance.json:1:1\nconflicting values null and [1,2] (mismatched types null and list):\n    generated.cue:2:1\n    instance.json:1:1\nconflicting values number and [1,2] (mismatched types number and list):\n    generated.cue:2:15\n    instance.json:1:1\nconflicting values string and [1,2] (mismatched types string and list):\n    generated.cue:2:24\n    instance.json:1:1\n",
   126  					"v3": "6 errors in empty disjunction:\nconflicting values [1,2] and bool (mismatched types list and bool):\n    generated.cue:2:8\n    instance.json:1:1\nconflicting values [1,2] and null (mismatched types list and null):\n    generated.cue:2:1\n    instance.json:1:1\nconflicting values [1,2] and number (mismatched types list and number):\n    generated.cue:2:15\n    instance.json:1:1\nconflicting values [1,2] and string (mismatched types list and string):\n    generated.cue:2:24\n    instance.json:1:1\nconflicting values [1,2] and {...} (mismatched types list and struct):\n    generated.cue:2:45\n    instance.json:1:1\nincompatible list lengths (2 and 3):\n    generated.cue:2:33\n"
   127  				}
   128  			},
   129  			{
   130  				"description": "equal number of items present",
   131  				"data": [
   132  					1,
   133  					2,
   134  					3
   135  				],
   136  				"valid": true
   137  			},
   138  			{
   139  				"description": "additional items are not permitted",
   140  				"data": [
   141  					1,
   142  					2,
   143  					3,
   144  					4
   145  				],
   146  				"valid": false
   147  			}
   148  		]
   149  	},
   150  	{
   151  		"description": "additionalItems as false without items",
   152  		"schema": {
   153  			"additionalItems": false
   154  		},
   155  		"tests": [
   156  			{
   157  				"description": "items defaults to empty schema so everything is valid",
   158  				"data": [
   159  					1,
   160  					2,
   161  					3,
   162  					4,
   163  					5
   164  				],
   165  				"valid": true
   166  			},
   167  			{
   168  				"description": "ignores non-arrays",
   169  				"data": {
   170  					"foo": "bar"
   171  				},
   172  				"valid": true
   173  			}
   174  		]
   175  	},
   176  	{
   177  		"description": "additionalItems are allowed by default",
   178  		"schema": {
   179  			"items": [
   180  				{
   181  					"type": "integer"
   182  				}
   183  			]
   184  		},
   185  		"tests": [
   186  			{
   187  				"description": "only the first item is validated",
   188  				"data": [
   189  					1,
   190  					"foo",
   191  					false
   192  				],
   193  				"valid": true
   194  			}
   195  		]
   196  	},
   197  	{
   198  		"description": "additionalItems does not look in applicators, valid case",
   199  		"schema": {
   200  			"allOf": [
   201  				{
   202  					"items": [
   203  						{
   204  							"type": "integer"
   205  						}
   206  					]
   207  				}
   208  			],
   209  			"additionalItems": {
   210  				"type": "boolean"
   211  			}
   212  		},
   213  		"tests": [
   214  			{
   215  				"description": "items defined in allOf are not examined",
   216  				"data": [
   217  					1,
   218  					null
   219  				],
   220  				"valid": true
   221  			}
   222  		]
   223  	},
   224  	{
   225  		"description": "additionalItems does not look in applicators, invalid case",
   226  		"schema": {
   227  			"allOf": [
   228  				{
   229  					"items": [
   230  						{
   231  							"type": "integer"
   232  						},
   233  						{
   234  							"type": "string"
   235  						}
   236  					]
   237  				}
   238  			],
   239  			"items": [
   240  				{
   241  					"type": "integer"
   242  				}
   243  			],
   244  			"additionalItems": {
   245  				"type": "boolean"
   246  			}
   247  		},
   248  		"tests": [
   249  			{
   250  				"description": "items defined in allOf are not examined",
   251  				"data": [
   252  					1,
   253  					"hello"
   254  				],
   255  				"valid": false
   256  			}
   257  		]
   258  	},
   259  	{
   260  		"description": "items validation adjusts the starting index for additionalItems",
   261  		"schema": {
   262  			"items": [
   263  				{
   264  					"type": "string"
   265  				}
   266  			],
   267  			"additionalItems": {
   268  				"type": "integer"
   269  			}
   270  		},
   271  		"tests": [
   272  			{
   273  				"description": "valid items",
   274  				"data": [
   275  					"x",
   276  					2,
   277  					3
   278  				],
   279  				"valid": true
   280  			},
   281  			{
   282  				"description": "wrong type of second item",
   283  				"data": [
   284  					"x",
   285  					"y"
   286  				],
   287  				"valid": false
   288  			}
   289  		]
   290  	},
   291  	{
   292  		"description": "additionalItems with heterogeneous array",
   293  		"schema": {
   294  			"items": [
   295  				{}
   296  			],
   297  			"additionalItems": false
   298  		},
   299  		"tests": [
   300  			{
   301  				"description": "heterogeneous invalid instance",
   302  				"data": [
   303  					"foo",
   304  					"bar",
   305  					37
   306  				],
   307  				"valid": false
   308  			},
   309  			{
   310  				"description": "valid instance",
   311  				"data": [
   312  					null
   313  				],
   314  				"valid": true
   315  			}
   316  		]
   317  	},
   318  	{
   319  		"description": "additionalItems with null instance elements",
   320  		"schema": {
   321  			"additionalItems": {
   322  				"type": "null"
   323  			}
   324  		},
   325  		"tests": [
   326  			{
   327  				"description": "allows null elements",
   328  				"data": [
   329  					null
   330  				],
   331  				"valid": true
   332  			}
   333  		]
   334  	}
   335  ]