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

     1  [
     2  	{
     3  		"description": "patternProperties validates properties matching a regex",
     4  		"schema": {
     5  			"patternProperties": {
     6  				"f.*o": {
     7  					"type": "integer"
     8  				}
     9  			}
    10  		},
    11  		"tests": [
    12  			{
    13  				"description": "a single valid match is valid",
    14  				"data": {
    15  					"foo": 1
    16  				},
    17  				"valid": true
    18  			},
    19  			{
    20  				"description": "multiple valid matches is valid",
    21  				"data": {
    22  					"foo": 1,
    23  					"foooooo": 2
    24  				},
    25  				"valid": true
    26  			},
    27  			{
    28  				"description": "a single invalid match is invalid",
    29  				"data": {
    30  					"foo": "bar",
    31  					"fooooo": 2
    32  				},
    33  				"valid": false
    34  			},
    35  			{
    36  				"description": "multiple invalid matches is invalid",
    37  				"data": {
    38  					"foo": "bar",
    39  					"foooooo": "baz"
    40  				},
    41  				"valid": false
    42  			},
    43  			{
    44  				"description": "ignores arrays",
    45  				"data": [
    46  					"foo"
    47  				],
    48  				"valid": true
    49  			},
    50  			{
    51  				"description": "ignores strings",
    52  				"data": "foo",
    53  				"valid": true
    54  			},
    55  			{
    56  				"description": "ignores other non-objects",
    57  				"data": 12,
    58  				"valid": true
    59  			}
    60  		]
    61  	},
    62  	{
    63  		"description": "multiple simultaneous patternProperties are validated",
    64  		"schema": {
    65  			"patternProperties": {
    66  				"a*": {
    67  					"type": "integer"
    68  				},
    69  				"aaa*": {
    70  					"maximum": 20
    71  				}
    72  			}
    73  		},
    74  		"tests": [
    75  			{
    76  				"description": "a single valid match is valid",
    77  				"data": {
    78  					"a": 21
    79  				},
    80  				"valid": true
    81  			},
    82  			{
    83  				"description": "a simultaneous match is valid",
    84  				"data": {
    85  					"aaaa": 18
    86  				},
    87  				"valid": true
    88  			},
    89  			{
    90  				"description": "multiple matches is valid",
    91  				"data": {
    92  					"a": 21,
    93  					"aaaa": 18
    94  				},
    95  				"valid": true
    96  			},
    97  			{
    98  				"description": "an invalid due to one is invalid",
    99  				"data": {
   100  					"a": "bar"
   101  				},
   102  				"valid": false
   103  			},
   104  			{
   105  				"description": "an invalid due to the other is invalid",
   106  				"data": {
   107  					"aaaa": 31
   108  				},
   109  				"valid": false
   110  			},
   111  			{
   112  				"description": "an invalid due to both is invalid",
   113  				"data": {
   114  					"aaa": "foo",
   115  					"aaaa": 31
   116  				},
   117  				"valid": false
   118  			}
   119  		]
   120  	},
   121  	{
   122  		"description": "regexes are not anchored by default and are case sensitive",
   123  		"schema": {
   124  			"patternProperties": {
   125  				"[0-9]{2,}": {
   126  					"type": "boolean"
   127  				},
   128  				"X_": {
   129  					"type": "string"
   130  				}
   131  			}
   132  		},
   133  		"tests": [
   134  			{
   135  				"description": "non recognized members are ignored",
   136  				"data": {
   137  					"answer 1": "42"
   138  				},
   139  				"valid": true
   140  			},
   141  			{
   142  				"description": "recognized members are accounted for",
   143  				"data": {
   144  					"a31b": null
   145  				},
   146  				"valid": false
   147  			},
   148  			{
   149  				"description": "regexes are case sensitive",
   150  				"data": {
   151  					"a_x_3": 3
   152  				},
   153  				"valid": true
   154  			},
   155  			{
   156  				"description": "regexes are case sensitive, 2",
   157  				"data": {
   158  					"a_X_3": 3
   159  				},
   160  				"valid": false
   161  			}
   162  		]
   163  	},
   164  	{
   165  		"description": "patternProperties with boolean schemas",
   166  		"schema": {
   167  			"patternProperties": {
   168  				"f.*": true,
   169  				"b.*": false
   170  			}
   171  		},
   172  		"tests": [
   173  			{
   174  				"description": "object with property matching schema true is valid",
   175  				"data": {
   176  					"foo": 1
   177  				},
   178  				"valid": true
   179  			},
   180  			{
   181  				"description": "object with property matching schema false is invalid",
   182  				"data": {
   183  					"bar": 2
   184  				},
   185  				"valid": false
   186  			},
   187  			{
   188  				"description": "object with both properties is invalid",
   189  				"data": {
   190  					"foo": 1,
   191  					"bar": 2
   192  				},
   193  				"valid": false
   194  			},
   195  			{
   196  				"description": "object with a property matching both true and false is invalid",
   197  				"data": {
   198  					"foobar": 1
   199  				},
   200  				"valid": false
   201  			},
   202  			{
   203  				"description": "empty object is valid",
   204  				"data": {},
   205  				"valid": true
   206  			}
   207  		]
   208  	},
   209  	{
   210  		"description": "patternProperties with null valued instance properties",
   211  		"schema": {
   212  			"patternProperties": {
   213  				"^.*bar$": {
   214  					"type": "null"
   215  				}
   216  			}
   217  		},
   218  		"tests": [
   219  			{
   220  				"description": "allows null values",
   221  				"data": {
   222  					"foobar": null
   223  				},
   224  				"valid": true
   225  			}
   226  		]
   227  	}
   228  ]