@@ -191,19 +191,19 @@ export function validateArray(schema) {
191191 return { isValid : false , msg : "Array 'items' must have a 'type' or '$ref' or 'oneOf' or 'anyOf' or 'allOf'" } ;
192192 }
193193
194- if ( schema . hasOwnProperty ( 'oneOf' ) ) {
194+ if ( schema . items . hasOwnProperty ( 'oneOf' ) ) {
195195 validation = validateOneOf ( schema . items ) ;
196196 if ( ! validation . isValid )
197197 return validation ;
198198 }
199199
200- if ( schema . hasOwnProperty ( 'anyOf' ) ) {
200+ if ( schema . items . hasOwnProperty ( 'anyOf' ) ) {
201201 validation = validateAnyOf ( schema . items ) ;
202202 if ( ! validation . isValid )
203203 return validation ;
204204 }
205205
206- if ( schema . hasOwnProperty ( 'allOf' ) ) {
206+ if ( schema . items . hasOwnProperty ( 'allOf' ) ) {
207207 validation = validateAllOf ( schema . items ) ;
208208 if ( ! validation . isValid )
209209 return validation ;
@@ -282,7 +282,8 @@ function validateSubschemas(schema, keyword) {
282282
283283 Validation:
284284 1. Must be an array
285- 2. If directly inside an object, each subschema in array must have 'properties' or 'keys keyword
285+ 2. Must have at least one subschema
286+ 3. If directly inside an object, each subschema in array must have 'properties' or 'keys keyword
286287 */
287288 let subschemas = schema [ keyword ] ;
288289
@@ -292,6 +293,12 @@ function validateSubschemas(schema, keyword) {
292293 msg : "'" + keyword + "' property must be an array"
293294 } ;
294295
296+ if ( ! subschemas . length )
297+ return {
298+ isValid : false ,
299+ msg : "'" + keyword + "' must contain at least one subschema"
300+ } ;
301+
295302 for ( let i = 0 ; i < subschemas . length ; i ++ ) {
296303 let subschema = subschemas [ i ] ;
297304 let subType = getSchemaType ( subschema ) ;
0 commit comments