Skip to content

Commit

Permalink
fix(document): ensure nested mixed validator gets called exactly once
Browse files Browse the repository at this point in the history
Fix #8117
  • Loading branch information
vkarpov15 committed Sep 4, 2019
1 parent a57e491 commit 6a9abe8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -2025,10 +2025,7 @@ function _getPathsToValidate(doc) {
_v = _v.toObject({ transform: false });
}
const flat = flatten(_v, pathToCheck, flattenOptions, doc.schema);
const _subpaths = Object.keys(flat).map(function(p) {
return pathToCheck + '.' + p;
});
paths = paths.concat(_subpaths);
paths = paths.concat(Object.keys(flat));
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7938,7 +7938,7 @@ describe('document', function() {
});

it('only calls validator once on nested mixed validator (gh-8117)', function() {
let called = [];
const called = [];
const Model = db.model('gh8117', Schema({
name: { type: String },
level1: {
Expand Down

0 comments on commit 6a9abe8

Please sign in to comment.