Your IP : 216.73.217.13


Current Path : /home/deltalab/PMS/sms-connector/node_modules/mongoose/lib/plugins/
Upload File :
Current File : //home/deltalab/PMS/sms-connector/node_modules/mongoose/lib/plugins/clearValidating.js

'use strict';

/*!
 * ignore
 */

module.exports = function(schema) {
  // `this.$__.validating` tracks whether there are multiple validations running
  // in parallel. We need to clear `this.$__.validating` before post hooks for gh-8597
  const unshift = true;
  schema.s.hooks.post('validate', false, function() {
    if (this.ownerDocument) {
      return;
    }

    this.$__.validating = null;
  }, unshift);

  schema.s.hooks.post('validate', false, function(error, res, next) {
    if (this.ownerDocument) {
      next();
      return;
    }

    this.$__.validating = null;
    next();
  }, unshift);
};