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