From bb25b0626a7dcedd8050f1177c80c9fb7646b54a Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Thu, 20 Feb 2020 15:55:59 -0500 Subject: [PATCH] fix(document): allow calling `validate()` in post validate hook without causing parallel validation error Fix #8597 --- lib/document.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/document.js b/lib/document.js index 3d03860e550..e193b34a50d 100644 --- a/lib/document.js +++ b/lib/document.js @@ -2088,7 +2088,6 @@ Document.prototype.validate = function(pathsToValidate, options, callback) { } this.$__validate(pathsToValidate, options, (error) => { - this.$__.validating = null; this.$op = null; cb(error); }); @@ -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