Skip to content

Commit

Permalink
fix(update): handle subdocument pre('validate') errors in update vali…
Browse files Browse the repository at this point in the history
…dation

Fix #7187
  • Loading branch information
vkarpov15 committed Oct 11, 2019
1 parent 98b3b09 commit 936ddfb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -1932,9 +1932,11 @@ Document.prototype.validate = function(options, callback) {
options = null;
}

return utils.promiseOrCallback(callback, cb => this.$__validate(options, function(error) {
cb(error);
}), this.constructor.events);
return utils.promiseOrCallback(callback, cb => {
this.$__validate(options, function(error) {
cb(error);
});
}, this.constructor.events);
};

/*!
Expand Down
3 changes: 3 additions & 0 deletions lib/helpers/updateValidators.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ module.exports = function(query, schema, castedDoc, options, callback) {
_err.path = updates[i] + '.' + key;
validationErrors.push(_err);
}
} else {
err.path = updates[i];
validationErrors.push(err);
}
}
callback(null);
Expand Down

0 comments on commit 936ddfb

Please sign in to comment.