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