Skip to content

Commit 664674f

Browse files
committed
Update behavior when validating schema
Only an object should check for required properties.
1 parent 538d4f4 commit 664674f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/validators/spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,14 @@ function validateRequiredPropertiesExist (schema, schemaId) {
330330
}
331331
}
332332

333+
// The "required" keyword is only applicable for objects
334+
if (Array.isArray(schema.type) && !schema.type.includes("object")) {
335+
return;
336+
}
337+
else if (!Array.isArray(schema.type) && schema.type !== "object") {
338+
return;
339+
}
340+
333341
if (schema.required && Array.isArray(schema.required)) {
334342
let props = {};
335343
collectProperties(schema, props);

0 commit comments

Comments
 (0)