Skip to content

Commit

Permalink
fix(document): check path exists before checking for required
Browse files Browse the repository at this point in the history
Fix #6974
  • Loading branch information
vkarpov15 committed Sep 23, 2018
1 parent 2221d72 commit 05aa04d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/document.js
Expand Up @@ -1628,7 +1628,7 @@ function _evaluateRequiredFunctions(doc) {
Object.keys(doc.$__.activePaths.states.require).forEach(path => {
const p = doc.schema.path(path);

if (typeof p.originalRequiredValue === 'function') {
if (p != null && typeof p.originalRequiredValue === 'function') {
doc.$__.cachedRequired[path] = p.originalRequiredValue.call(doc);
}
});
Expand Down
1 change: 1 addition & 0 deletions lib/schematype.js
Expand Up @@ -636,6 +636,7 @@ SchemaType.prototype.required = function(required, message) {
}, this);

this.isRequired = false;
delete this.originalRequiredValue;
return this;
}

Expand Down

0 comments on commit 05aa04d

Please sign in to comment.