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

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