cuelang.org/go@v0.13.0/encoding/jsonschema/testdata/external/tests/draft2020-12/const.json (about)

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