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

     1  [
     2  	{
     3  		"description": "required validation",
     4  		"schema": {
     5  			"properties": {
     6  				"foo": {},
     7  				"bar": {}
     8  			},
     9  			"required": [
    10  				"foo"
    11  			]
    12  		},
    13  		"tests": [
    14  			{
    15  				"description": "present required property is valid",
    16  				"data": {
    17  					"foo": 1
    18  				},
    19  				"valid": true
    20  			},
    21  			{
    22  				"description": "non-present required property is invalid",
    23  				"data": {
    24  					"bar": 1
    25  				},
    26  				"valid": false
    27  			},
    28  			{
    29  				"description": "ignores arrays",
    30  				"data": [],
    31  				"valid": true
    32  			},
    33  			{
    34  				"description": "ignores strings",
    35  				"data": "",
    36  				"valid": true
    37  			},
    38  			{
    39  				"description": "ignores other non-objects",
    40  				"data": 12,
    41  				"valid": true
    42  			}
    43  		]
    44  	},
    45  	{
    46  		"description": "required default validation",
    47  		"schema": {
    48  			"properties": {
    49  				"foo": {}
    50  			}
    51  		},
    52  		"tests": [
    53  			{
    54  				"description": "not required by default",
    55  				"data": {},
    56  				"valid": true
    57  			}
    58  		]
    59  	},
    60  	{
    61  		"description": "required with empty array",
    62  		"schema": {
    63  			"properties": {
    64  				"foo": {}
    65  			},
    66  			"required": []
    67  		},
    68  		"tests": [
    69  			{
    70  				"description": "property not required",
    71  				"data": {},
    72  				"valid": true
    73  			}
    74  		]
    75  	},
    76  	{
    77  		"description": "required with escaped characters",
    78  		"schema": {
    79  			"required": [
    80  				"foo\nbar",
    81  				"foo\"bar",
    82  				"foo\\bar",
    83  				"foo\rbar",
    84  				"foo\tbar",
    85  				"foo\fbar"
    86  			]
    87  		},
    88  		"tests": [
    89  			{
    90  				"description": "object with all properties present is valid",
    91  				"data": {
    92  					"foo\nbar": 1,
    93  					"foo\"bar": 1,
    94  					"foo\\bar": 1,
    95  					"foo\rbar": 1,
    96  					"foo\tbar": 1,
    97  					"foo\fbar": 1
    98  				},
    99  				"valid": true
   100  			},
   101  			{
   102  				"description": "object with some properties missing is invalid",
   103  				"data": {
   104  					"foo\nbar": "1",
   105  					"foo\"bar": "1"
   106  				},
   107  				"valid": false
   108  			}
   109  		]
   110  	},
   111  	{
   112  		"description": "required properties whose names are Javascript object property names",
   113  		"comment": "Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object.",
   114  		"schema": {
   115  			"required": [
   116  				"__proto__",
   117  				"toString",
   118  				"constructor"
   119  			]
   120  		},
   121  		"tests": [
   122  			{
   123  				"description": "ignores arrays",
   124  				"data": [],
   125  				"valid": true
   126  			},
   127  			{
   128  				"description": "ignores other non-objects",
   129  				"data": 12,
   130  				"valid": true
   131  			},
   132  			{
   133  				"description": "none of the properties mentioned",
   134  				"data": {},
   135  				"valid": false
   136  			},
   137  			{
   138  				"description": "__proto__ present",
   139  				"data": {
   140  					"__proto__": "foo"
   141  				},
   142  				"valid": false
   143  			},
   144  			{
   145  				"description": "toString present",
   146  				"data": {
   147  					"toString": {
   148  						"length": 37
   149  					}
   150  				},
   151  				"valid": false
   152  			},
   153  			{
   154  				"description": "constructor present",
   155  				"data": {
   156  					"constructor": {
   157  						"length": 37
   158  					}
   159  				},
   160  				"valid": false
   161  			},
   162  			{
   163  				"description": "all present",
   164  				"data": {
   165  					"__proto__": 12,
   166  					"toString": {
   167  						"length": "foo"
   168  					},
   169  					"constructor": 37
   170  				},
   171  				"valid": true
   172  			}
   173  		]
   174  	}
   175  ]