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

     1  [
     2  	{
     3  		"description": "a schema given for items",
     4  		"schema": {
     5  			"items": {
     6  				"type": "integer"
     7  			}
     8  		},
     9  		"tests": [
    10  			{
    11  				"description": "valid items",
    12  				"data": [
    13  					1,
    14  					2,
    15  					3
    16  				],
    17  				"valid": true
    18  			},
    19  			{
    20  				"description": "wrong type of items",
    21  				"data": [
    22  					1,
    23  					"x"
    24  				],
    25  				"valid": false
    26  			},
    27  			{
    28  				"description": "ignores non-arrays",
    29  				"data": {
    30  					"foo": "bar"
    31  				},
    32  				"valid": true
    33  			},
    34  			{
    35  				"description": "JavaScript pseudo-array is valid",
    36  				"data": {
    37  					"0": "invalid",
    38  					"length": 1
    39  				},
    40  				"valid": true
    41  			}
    42  		]
    43  	},
    44  	{
    45  		"description": "an array of schemas for items",
    46  		"schema": {
    47  			"items": [
    48  				{
    49  					"type": "integer"
    50  				},
    51  				{
    52  					"type": "string"
    53  				}
    54  			]
    55  		},
    56  		"tests": [
    57  			{
    58  				"description": "correct types",
    59  				"data": [
    60  					1,
    61  					"foo"
    62  				],
    63  				"valid": true
    64  			},
    65  			{
    66  				"description": "wrong types",
    67  				"data": [
    68  					"foo",
    69  					1
    70  				],
    71  				"valid": false
    72  			},
    73  			{
    74  				"description": "incomplete array of items",
    75  				"data": [
    76  					1
    77  				],
    78  				"valid": true,
    79  				"skip": {
    80  					"v2": "5 errors in empty disjunction:\nconflicting values [1] and {...} (mismatched types list and struct):\n    generated.cue:2:1\n    generated.cue:2:54\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",
    81  					"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:54\n    instance.json:1:1\nincompatible list lengths (1 and 3):\n    generated.cue:2:33\n"
    82  				}
    83  			},
    84  			{
    85  				"description": "array with additional items",
    86  				"data": [
    87  					1,
    88  					"foo",
    89  					true
    90  				],
    91  				"valid": true
    92  			},
    93  			{
    94  				"description": "empty array",
    95  				"data": [],
    96  				"valid": true,
    97  				"skip": {
    98  					"v2": "5 errors in empty disjunction:\nconflicting values [] and {...} (mismatched types list and struct):\n    generated.cue:2:1\n    generated.cue:2:54\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",
    99  					"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:54\n    instance.json:1:1\nincompatible list lengths (0 and 3):\n    generated.cue:2:33\n"
   100  				}
   101  			},
   102  			{
   103  				"description": "JavaScript pseudo-array is valid",
   104  				"data": {
   105  					"0": "invalid",
   106  					"1": "valid",
   107  					"length": 2
   108  				},
   109  				"valid": true
   110  			}
   111  		]
   112  	},
   113  	{
   114  		"description": "items and subitems",
   115  		"schema": {
   116  			"definitions": {
   117  				"item": {
   118  					"type": "array",
   119  					"additionalItems": false,
   120  					"items": [
   121  						{
   122  							"$ref": "#/definitions/sub-item"
   123  						},
   124  						{
   125  							"$ref": "#/definitions/sub-item"
   126  						}
   127  					]
   128  				},
   129  				"sub-item": {
   130  					"type": "object",
   131  					"required": [
   132  						"foo"
   133  					]
   134  				}
   135  			},
   136  			"type": "array",
   137  			"additionalItems": false,
   138  			"items": [
   139  				{
   140  					"$ref": "#/definitions/item"
   141  				},
   142  				{
   143  					"$ref": "#/definitions/item"
   144  				},
   145  				{
   146  					"$ref": "#/definitions/item"
   147  				}
   148  			]
   149  		},
   150  		"tests": [
   151  			{
   152  				"description": "valid items",
   153  				"data": [
   154  					[
   155  						{
   156  							"foo": null
   157  						},
   158  						{
   159  							"foo": null
   160  						}
   161  					],
   162  					[
   163  						{
   164  							"foo": null
   165  						},
   166  						{
   167  							"foo": null
   168  						}
   169  					],
   170  					[
   171  						{
   172  							"foo": null
   173  						},
   174  						{
   175  							"foo": null
   176  						}
   177  					]
   178  				],
   179  				"valid": true
   180  			},
   181  			{
   182  				"description": "too many items",
   183  				"data": [
   184  					[
   185  						{
   186  							"foo": null
   187  						},
   188  						{
   189  							"foo": null
   190  						}
   191  					],
   192  					[
   193  						{
   194  							"foo": null
   195  						},
   196  						{
   197  							"foo": null
   198  						}
   199  					],
   200  					[
   201  						{
   202  							"foo": null
   203  						},
   204  						{
   205  							"foo": null
   206  						}
   207  					],
   208  					[
   209  						{
   210  							"foo": null
   211  						},
   212  						{
   213  							"foo": null
   214  						}
   215  					]
   216  				],
   217  				"valid": false
   218  			},
   219  			{
   220  				"description": "too many sub-items",
   221  				"data": [
   222  					[
   223  						{
   224  							"foo": null
   225  						},
   226  						{
   227  							"foo": null
   228  						},
   229  						{
   230  							"foo": null
   231  						}
   232  					],
   233  					[
   234  						{
   235  							"foo": null
   236  						},
   237  						{
   238  							"foo": null
   239  						}
   240  					],
   241  					[
   242  						{
   243  							"foo": null
   244  						},
   245  						{
   246  							"foo": null
   247  						}
   248  					]
   249  				],
   250  				"valid": false
   251  			},
   252  			{
   253  				"description": "wrong item",
   254  				"data": [
   255  					{
   256  						"foo": null
   257  					},
   258  					[
   259  						{
   260  							"foo": null
   261  						},
   262  						{
   263  							"foo": null
   264  						}
   265  					],
   266  					[
   267  						{
   268  							"foo": null
   269  						},
   270  						{
   271  							"foo": null
   272  						}
   273  					]
   274  				],
   275  				"valid": false
   276  			},
   277  			{
   278  				"description": "wrong sub-item",
   279  				"data": [
   280  					[
   281  						{},
   282  						{
   283  							"foo": null
   284  						}
   285  					],
   286  					[
   287  						{
   288  							"foo": null
   289  						},
   290  						{
   291  							"foo": null
   292  						}
   293  					],
   294  					[
   295  						{
   296  							"foo": null
   297  						},
   298  						{
   299  							"foo": null
   300  						}
   301  					]
   302  				],
   303  				"valid": false
   304  			},
   305  			{
   306  				"description": "fewer items is valid",
   307  				"data": [
   308  					[
   309  						{
   310  							"foo": null
   311  						}
   312  					],
   313  					[
   314  						{
   315  							"foo": null
   316  						}
   317  					]
   318  				],
   319  				"valid": true,
   320  				"skip": {
   321  					"v2": "incompatible list lengths (2 and 3)\n0: incompatible list lengths (1 and 2)\n1: incompatible list lengths (1 and 2)\n",
   322  					"v3": "incompatible list lengths (2 and 3):\n    generated.cue:2:1\n0: incompatible list lengths (1 and 2):\n    generated.cue:9:8\n"
   323  				}
   324  			}
   325  		]
   326  	},
   327  	{
   328  		"description": "nested items",
   329  		"schema": {
   330  			"type": "array",
   331  			"items": {
   332  				"type": "array",
   333  				"items": {
   334  					"type": "array",
   335  					"items": {
   336  						"type": "array",
   337  						"items": {
   338  							"type": "number"
   339  						}
   340  					}
   341  				}
   342  			}
   343  		},
   344  		"tests": [
   345  			{
   346  				"description": "valid nested array",
   347  				"data": [
   348  					[
   349  						[
   350  							[
   351  								1
   352  							]
   353  						],
   354  						[
   355  							[
   356  								2
   357  							],
   358  							[
   359  								3
   360  							]
   361  						]
   362  					],
   363  					[
   364  						[
   365  							[
   366  								4
   367  							],
   368  							[
   369  								5
   370  							],
   371  							[
   372  								6
   373  							]
   374  						]
   375  					]
   376  				],
   377  				"valid": true
   378  			},
   379  			{
   380  				"description": "nested array with invalid type",
   381  				"data": [
   382  					[
   383  						[
   384  							[
   385  								"1"
   386  							]
   387  						],
   388  						[
   389  							[
   390  								2
   391  							],
   392  							[
   393  								3
   394  							]
   395  						]
   396  					],
   397  					[
   398  						[
   399  							[
   400  								4
   401  							],
   402  							[
   403  								5
   404  							],
   405  							[
   406  								6
   407  							]
   408  						]
   409  					]
   410  				],
   411  				"valid": false
   412  			},
   413  			{
   414  				"description": "not deep enough",
   415  				"data": [
   416  					[
   417  						[
   418  							1
   419  						],
   420  						[
   421  							2
   422  						],
   423  						[
   424  							3
   425  						]
   426  					],
   427  					[
   428  						[
   429  							4
   430  						],
   431  						[
   432  							5
   433  						],
   434  						[
   435  							6
   436  						]
   437  					]
   438  				],
   439  				"valid": false
   440  			}
   441  		]
   442  	},
   443  	{
   444  		"description": "items with null instance elements",
   445  		"schema": {
   446  			"items": {
   447  				"type": "null"
   448  			}
   449  		},
   450  		"tests": [
   451  			{
   452  				"description": "allows null elements",
   453  				"data": [
   454  					null
   455  				],
   456  				"valid": true
   457  			}
   458  		]
   459  	},
   460  	{
   461  		"description": "array-form items with null instance elements",
   462  		"schema": {
   463  			"items": [
   464  				{
   465  					"type": "null"
   466  				}
   467  			]
   468  		},
   469  		"tests": [
   470  			{
   471  				"description": "allows null elements",
   472  				"data": [
   473  					null
   474  				],
   475  				"valid": true
   476  			}
   477  		]
   478  	}
   479  ]