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

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