clearValidating.js 614 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. /*!
  3. * ignore
  4. */
  5. module.exports = function(schema) {
  6. // `this.$__.validating` tracks whether there are multiple validations running
  7. // in parallel. We need to clear `this.$__.validating` before post hooks for gh-8597
  8. const unshift = true;
  9. schema.s.hooks.post('validate', false, function() {
  10. if (this.$isSubdocument) {
  11. return;
  12. }
  13. this.$__.validating = null;
  14. }, unshift);
  15. schema.s.hooks.post('validate', false, function(error, res, next) {
  16. if (this.$isSubdocument) {
  17. next();
  18. return;
  19. }
  20. this.$__.validating = null;
  21. next();
  22. }, unshift);
  23. };