Skip to content

Commit

Permalink
fix(document): allow calling validate() in post validate hook witho…
Browse files Browse the repository at this point in the history
…ut causing parallel validation error

Fix #8597
  • Loading branch information
vkarpov15 committed Feb 20, 2020
1 parent b895e01 commit bb25b06
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -2088,7 +2088,6 @@ Document.prototype.validate = function(pathsToValidate, options, callback) {
}

this.$__validate(pathsToValidate, options, (error) => {
this.$__.validating = null;
this.$op = null;
cb(error);
});
Expand Down Expand Up @@ -2274,6 +2273,8 @@ Document.prototype.$__validate = function(pathsToValidate, options, callback) {
this.$__.cachedRequired = {};
this.emit('validate', _this);
this.constructor.emit('validate', _this);

this.$__.validating = null;
if (validationError) {
for (const key in validationError.errors) {
// Make sure cast errors persist
Expand Down

0 comments on commit bb25b06

Please sign in to comment.