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 escaped characters", 56 "schema": { 57 "required": [ 58 "foo\nbar", 59 "foo\"bar", 60 "foo\\bar", 61 "foo\rbar", 62 "foo\tbar", 63 "foo\fbar" 64 ] 65 }, 66 "tests": [ 67 { 68 "description": "object with all properties present is valid", 69 "data": { 70 "foo\nbar": 1, 71 "foo\"bar": 1, 72 "foo\\bar": 1, 73 "foo\rbar": 1, 74 "foo\tbar": 1, 75 "foo\fbar": 1 76 }, 77 "valid": true 78 }, 79 { 80 "description": "object with some properties missing is invalid", 81 "data": { 82 "foo\nbar": "1", 83 "foo\"bar": "1" 84 }, 85 "valid": false 86 } 87 ] 88 }, 89 { 90 "description": "required properties whose names are Javascript object property names", 91 "comment": "Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object.", 92 "schema": { "required": ["__proto__", "toString", "constructor"] }, 93 "tests": [ 94 { 95 "description": "ignores arrays", 96 "data": [], 97 "valid": true 98 }, 99 { 100 "description": "ignores other non-objects", 101 "data": 12, 102 "valid": true 103 }, 104 { 105 "description": "none of the properties mentioned", 106 "data": {}, 107 "valid": false 108 }, 109 { 110 "description": "__proto__ present", 111 "data": { "__proto__": "foo" }, 112 "valid": false 113 }, 114 { 115 "description": "toString present", 116 "data": { "toString": { "length": 37 } }, 117 "valid": false 118 }, 119 { 120 "description": "constructor present", 121 "data": { "constructor": { "length": 37 } }, 122 "valid": false 123 }, 124 { 125 "description": "all present", 126 "data": { 127 "__proto__": 12, 128 "toString": { "length": "foo" }, 129 "constructor": 37 130 }, 131 "valid": true 132 } 133 ] 134 } 135] 136