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

     1  [
     2  	{
     3  		"description": "contains keyword validation",
     4  		"schema": {
     5  			"$schema": "https://json-schema.org/draft/2019-09/schema",
     6  			"contains": {
     7  				"minimum": 5
     8  			}
     9  		},
    10  		"tests": [
    11  			{
    12  				"description": "array with item matching schema (5) is valid",
    13  				"data": [
    14  					3,
    15  					4,
    16  					5
    17  				],
    18  				"valid": true
    19  			},
    20  			{
    21  				"description": "array with item matching schema (6) is valid",
    22  				"data": [
    23  					3,
    24  					4,
    25  					6
    26  				],
    27  				"valid": true
    28  			},
    29  			{
    30  				"description": "array with two items matching schema (5, 6) is valid",
    31  				"data": [
    32  					3,
    33  					4,
    34  					5,
    35  					6
    36  				],
    37  				"valid": true
    38  			},
    39  			{
    40  				"description": "array without items matching schema is invalid",
    41  				"data": [
    42  					2,
    43  					3,
    44  					4
    45  				],
    46  				"valid": false
    47  			},
    48  			{
    49  				"description": "empty array is invalid",
    50  				"data": [],
    51  				"valid": false
    52  			},
    53  			{
    54  				"description": "not array is valid",
    55  				"data": {},
    56  				"valid": true
    57  			}
    58  		]
    59  	},
    60  	{
    61  		"description": "contains keyword with const keyword",
    62  		"schema": {
    63  			"$schema": "https://json-schema.org/draft/2019-09/schema",
    64  			"contains": {
    65  				"const": 5
    66  			}
    67  		},
    68  		"tests": [
    69  			{
    70  				"description": "array with item 5 is valid",
    71  				"data": [
    72  					3,
    73  					4,
    74  					5
    75  				],
    76  				"valid": true
    77  			},
    78  			{
    79  				"description": "array with two items 5 is valid",
    80  				"data": [
    81  					3,
    82  					4,
    83  					5,
    84  					5
    85  				],
    86  				"valid": true
    87  			},
    88  			{
    89  				"description": "array without item 5 is invalid",
    90  				"data": [
    91  					1,
    92  					2,
    93  					3,
    94  					4
    95  				],
    96  				"valid": false
    97  			}
    98  		]
    99  	},
   100  	{
   101  		"description": "contains keyword with boolean schema true",
   102  		"schema": {
   103  			"$schema": "https://json-schema.org/draft/2019-09/schema",
   104  			"contains": true
   105  		},
   106  		"tests": [
   107  			{
   108  				"description": "any non-empty array is valid",
   109  				"data": [
   110  					"foo"
   111  				],
   112  				"valid": true
   113  			},
   114  			{
   115  				"description": "empty array is invalid",
   116  				"data": [],
   117  				"valid": false
   118  			}
   119  		]
   120  	},
   121  	{
   122  		"description": "contains keyword with boolean schema false",
   123  		"schema": {
   124  			"$schema": "https://json-schema.org/draft/2019-09/schema",
   125  			"contains": false
   126  		},
   127  		"tests": [
   128  			{
   129  				"description": "any non-empty array is invalid",
   130  				"data": [
   131  					"foo"
   132  				],
   133  				"valid": false
   134  			},
   135  			{
   136  				"description": "empty array is invalid",
   137  				"data": [],
   138  				"valid": false
   139  			},
   140  			{
   141  				"description": "non-arrays are valid",
   142  				"data": "contains does not apply to strings",
   143  				"valid": true
   144  			}
   145  		]
   146  	},
   147  	{
   148  		"description": "items + contains",
   149  		"schema": {
   150  			"$schema": "https://json-schema.org/draft/2019-09/schema",
   151  			"items": {
   152  				"multipleOf": 2
   153  			},
   154  			"contains": {
   155  				"multipleOf": 3
   156  			}
   157  		},
   158  		"tests": [
   159  			{
   160  				"description": "matches items, does not match contains",
   161  				"data": [
   162  					2,
   163  					4,
   164  					8
   165  				],
   166  				"valid": false
   167  			},
   168  			{
   169  				"description": "does not match items, matches contains",
   170  				"data": [
   171  					3,
   172  					6,
   173  					9
   174  				],
   175  				"valid": false
   176  			},
   177  			{
   178  				"description": "matches both items and contains",
   179  				"data": [
   180  					6,
   181  					12
   182  				],
   183  				"valid": true
   184  			},
   185  			{
   186  				"description": "matches neither items nor contains",
   187  				"data": [
   188  					1,
   189  					5
   190  				],
   191  				"valid": false
   192  			}
   193  		]
   194  	},
   195  	{
   196  		"description": "contains with false if subschema",
   197  		"schema": {
   198  			"$schema": "https://json-schema.org/draft/2019-09/schema",
   199  			"contains": {
   200  				"if": false,
   201  				"else": true
   202  			}
   203  		},
   204  		"tests": [
   205  			{
   206  				"description": "any non-empty array is valid",
   207  				"data": [
   208  					"foo"
   209  				],
   210  				"valid": true,
   211  				"skip": {
   212  					"v2": "6 errors in empty disjunction:\nconflicting values [\"foo\"] and {...} (mismatched types list and struct):\n    generated.cue:5:1\n    generated.cue:5:72\n    instance.json:1:1\nconflicting values bool and [\"foo\"] (mismatched types bool and list):\n    generated.cue:5:8\n    instance.json:1:1\nconflicting values null and [\"foo\"] (mismatched types null and list):\n    generated.cue:5:1\n    instance.json:1:1\nconflicting values number and [\"foo\"] (mismatched types number and list):\n    generated.cue:5:15\n    instance.json:1:1\nconflicting values string and [\"foo\"] (mismatched types string and list):\n    generated.cue:5:24\n    instance.json:1:1\nexplicit error (_|_ literal) in source:\n    generated.cue:5:58\n",
   213  					"v3": "6 errors in empty disjunction:\nconflicting values [\"foo\"] and bool (mismatched types list and bool):\n    generated.cue:5:8\n    instance.json:1:1\nconflicting values [\"foo\"] and null (mismatched types list and null):\n    generated.cue:5:1\n    instance.json:1:1\nconflicting values [\"foo\"] and number (mismatched types list and number):\n    generated.cue:5:15\n    instance.json:1:1\nconflicting values [\"foo\"] and string (mismatched types list and string):\n    generated.cue:5:24\n    instance.json:1:1\nconflicting values [\"foo\"] and {...} (mismatched types list and struct):\n    generated.cue:5:72\n    instance.json:1:1\nexplicit error (_|_ literal) in source:\n    generated.cue:5:58\n"
   214  				}
   215  			},
   216  			{
   217  				"description": "empty array is invalid",
   218  				"data": [],
   219  				"valid": false
   220  			}
   221  		]
   222  	},
   223  	{
   224  		"description": "contains with null instance elements",
   225  		"schema": {
   226  			"$schema": "https://json-schema.org/draft/2019-09/schema",
   227  			"contains": {
   228  				"type": "null"
   229  			}
   230  		},
   231  		"tests": [
   232  			{
   233  				"description": "allows null items",
   234  				"data": [
   235  					null
   236  				],
   237  				"valid": true
   238  			}
   239  		]
   240  	}
   241  ]