cuelang.org/go@v0.13.0/encoding/jsonschema/testdata/external/tests/draft4/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 escaped characters", 62 "schema": { 63 "required": [ 64 "foo\nbar", 65 "foo\"bar", 66 "foo\\bar", 67 "foo\rbar", 68 "foo\tbar", 69 "foo\fbar" 70 ] 71 }, 72 "tests": [ 73 { 74 "description": "object with all properties present is valid", 75 "data": { 76 "foo\nbar": 1, 77 "foo\"bar": 1, 78 "foo\\bar": 1, 79 "foo\rbar": 1, 80 "foo\tbar": 1, 81 "foo\fbar": 1 82 }, 83 "valid": true 84 }, 85 { 86 "description": "object with some properties missing is invalid", 87 "data": { 88 "foo\nbar": "1", 89 "foo\"bar": "1" 90 }, 91 "valid": false 92 } 93 ] 94 }, 95 { 96 "description": "required properties whose names are Javascript object property names", 97 "comment": "Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object.", 98 "schema": { 99 "required": [ 100 "__proto__", 101 "toString", 102 "constructor" 103 ] 104 }, 105 "tests": [ 106 { 107 "description": "ignores arrays", 108 "data": [], 109 "valid": true 110 }, 111 { 112 "description": "ignores other non-objects", 113 "data": 12, 114 "valid": true 115 }, 116 { 117 "description": "none of the properties mentioned", 118 "data": {}, 119 "valid": false 120 }, 121 { 122 "description": "__proto__ present", 123 "data": { 124 "__proto__": "foo" 125 }, 126 "valid": false 127 }, 128 { 129 "description": "toString present", 130 "data": { 131 "toString": { 132 "length": 37 133 } 134 }, 135 "valid": false 136 }, 137 { 138 "description": "constructor present", 139 "data": { 140 "constructor": { 141 "length": 37 142 } 143 }, 144 "valid": false 145 }, 146 { 147 "description": "all present", 148 "data": { 149 "__proto__": 12, 150 "toString": { 151 "length": "foo" 152 }, 153 "constructor": 37 154 }, 155 "valid": true 156 } 157 ] 158 } 159 ]