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

     1  [
     2  	{
     3  		"description": "oneOf",
     4  		"schema": {
     5  			"oneOf": [
     6  				{
     7  					"type": "integer"
     8  				},
     9  				{
    10  					"minimum": 2
    11  				}
    12  			]
    13  		},
    14  		"tests": [
    15  			{
    16  				"description": "first oneOf valid",
    17  				"data": 1,
    18  				"valid": true
    19  			},
    20  			{
    21  				"description": "second oneOf valid",
    22  				"data": 2.5,
    23  				"valid": true
    24  			},
    25  			{
    26  				"description": "both oneOf valid",
    27  				"data": 3,
    28  				"valid": false
    29  			},
    30  			{
    31  				"description": "neither oneOf valid",
    32  				"data": 1.5,
    33  				"valid": false
    34  			}
    35  		]
    36  	},
    37  	{
    38  		"description": "oneOf with base schema",
    39  		"schema": {
    40  			"type": "string",
    41  			"oneOf": [
    42  				{
    43  					"minLength": 2
    44  				},
    45  				{
    46  					"maxLength": 4
    47  				}
    48  			]
    49  		},
    50  		"tests": [
    51  			{
    52  				"description": "mismatch base schema",
    53  				"data": 3,
    54  				"valid": false
    55  			},
    56  			{
    57  				"description": "one oneOf valid",
    58  				"data": "foobar",
    59  				"valid": true
    60  			},
    61  			{
    62  				"description": "both oneOf valid",
    63  				"data": "foo",
    64  				"valid": false
    65  			}
    66  		]
    67  	},
    68  	{
    69  		"description": "oneOf with boolean schemas, all true",
    70  		"schema": {
    71  			"oneOf": [
    72  				true,
    73  				true,
    74  				true
    75  			]
    76  		},
    77  		"tests": [
    78  			{
    79  				"description": "any value is invalid",
    80  				"data": "foo",
    81  				"valid": false
    82  			}
    83  		]
    84  	},
    85  	{
    86  		"description": "oneOf with boolean schemas, one true",
    87  		"schema": {
    88  			"oneOf": [
    89  				true,
    90  				false,
    91  				false
    92  			]
    93  		},
    94  		"tests": [
    95  			{
    96  				"description": "any value is valid",
    97  				"data": "foo",
    98  				"valid": true
    99  			}
   100  		]
   101  	},
   102  	{
   103  		"description": "oneOf with boolean schemas, more than one true",
   104  		"schema": {
   105  			"oneOf": [
   106  				true,
   107  				true,
   108  				false
   109  			]
   110  		},
   111  		"tests": [
   112  			{
   113  				"description": "any value is invalid",
   114  				"data": "foo",
   115  				"valid": false
   116  			}
   117  		]
   118  	},
   119  	{
   120  		"description": "oneOf with boolean schemas, all false",
   121  		"schema": {
   122  			"oneOf": [
   123  				false,
   124  				false,
   125  				false
   126  			]
   127  		},
   128  		"tests": [
   129  			{
   130  				"description": "any value is invalid",
   131  				"data": "foo",
   132  				"valid": false
   133  			}
   134  		]
   135  	},
   136  	{
   137  		"description": "oneOf complex types",
   138  		"schema": {
   139  			"oneOf": [
   140  				{
   141  					"properties": {
   142  						"bar": {
   143  							"type": "integer"
   144  						}
   145  					},
   146  					"required": [
   147  						"bar"
   148  					]
   149  				},
   150  				{
   151  					"properties": {
   152  						"foo": {
   153  							"type": "string"
   154  						}
   155  					},
   156  					"required": [
   157  						"foo"
   158  					]
   159  				}
   160  			]
   161  		},
   162  		"tests": [
   163  			{
   164  				"description": "first oneOf valid (complex)",
   165  				"data": {
   166  					"bar": 2
   167  				},
   168  				"valid": true
   169  			},
   170  			{
   171  				"description": "second oneOf valid (complex)",
   172  				"data": {
   173  					"foo": "baz"
   174  				},
   175  				"valid": true
   176  			},
   177  			{
   178  				"description": "both oneOf valid (complex)",
   179  				"data": {
   180  					"foo": "baz",
   181  					"bar": 2
   182  				},
   183  				"valid": false
   184  			},
   185  			{
   186  				"description": "neither oneOf valid (complex)",
   187  				"data": {
   188  					"foo": 2,
   189  					"bar": "quux"
   190  				},
   191  				"valid": false
   192  			}
   193  		]
   194  	},
   195  	{
   196  		"description": "oneOf with empty schema",
   197  		"schema": {
   198  			"oneOf": [
   199  				{
   200  					"type": "number"
   201  				},
   202  				{}
   203  			]
   204  		},
   205  		"tests": [
   206  			{
   207  				"description": "one valid - valid",
   208  				"data": "foo",
   209  				"valid": true
   210  			},
   211  			{
   212  				"description": "both valid - invalid",
   213  				"data": 123,
   214  				"valid": false
   215  			}
   216  		]
   217  	},
   218  	{
   219  		"description": "oneOf with required",
   220  		"schema": {
   221  			"type": "object",
   222  			"oneOf": [
   223  				{
   224  					"required": [
   225  						"foo",
   226  						"bar"
   227  					]
   228  				},
   229  				{
   230  					"required": [
   231  						"foo",
   232  						"baz"
   233  					]
   234  				}
   235  			]
   236  		},
   237  		"tests": [
   238  			{
   239  				"description": "both invalid - invalid",
   240  				"data": {
   241  					"bar": 2
   242  				},
   243  				"valid": false
   244  			},
   245  			{
   246  				"description": "first valid - valid",
   247  				"data": {
   248  					"foo": 1,
   249  					"bar": 2
   250  				},
   251  				"valid": true
   252  			},
   253  			{
   254  				"description": "second valid - valid",
   255  				"data": {
   256  					"foo": 1,
   257  					"baz": 3
   258  				},
   259  				"valid": true
   260  			},
   261  			{
   262  				"description": "both valid - invalid",
   263  				"data": {
   264  					"foo": 1,
   265  					"bar": 2,
   266  					"baz": 3
   267  				},
   268  				"valid": false
   269  			}
   270  		]
   271  	},
   272  	{
   273  		"description": "oneOf with missing optional property",
   274  		"schema": {
   275  			"oneOf": [
   276  				{
   277  					"properties": {
   278  						"bar": true,
   279  						"baz": true
   280  					},
   281  					"required": [
   282  						"bar"
   283  					]
   284  				},
   285  				{
   286  					"properties": {
   287  						"foo": true
   288  					},
   289  					"required": [
   290  						"foo"
   291  					]
   292  				}
   293  			]
   294  		},
   295  		"tests": [
   296  			{
   297  				"description": "first oneOf valid",
   298  				"data": {
   299  					"bar": 8
   300  				},
   301  				"valid": true
   302  			},
   303  			{
   304  				"description": "second oneOf valid",
   305  				"data": {
   306  					"foo": "foo"
   307  				},
   308  				"valid": true
   309  			},
   310  			{
   311  				"description": "both oneOf valid",
   312  				"data": {
   313  					"foo": "foo",
   314  					"bar": 8
   315  				},
   316  				"valid": false
   317  			},
   318  			{
   319  				"description": "neither oneOf valid",
   320  				"data": {
   321  					"baz": "quux"
   322  				},
   323  				"valid": false
   324  			}
   325  		]
   326  	},
   327  	{
   328  		"description": "nested oneOf, to check validation semantics",
   329  		"schema": {
   330  			"oneOf": [
   331  				{
   332  					"oneOf": [
   333  						{
   334  							"type": "null"
   335  						}
   336  					]
   337  				}
   338  			]
   339  		},
   340  		"tests": [
   341  			{
   342  				"description": "null is valid",
   343  				"data": null,
   344  				"valid": true
   345  			},
   346  			{
   347  				"description": "anything non-null is invalid",
   348  				"data": 123,
   349  				"valid": false
   350  			}
   351  		]
   352  	}
   353  ]