MCPcopy
hub / github.com/sequelize/sequelize / _validateAndRunHooks

Method _validateAndRunHooks

lib/instance-validator.js:106–119  ·  lib/instance-validator.js::InstanceValidator._validateAndRunHooks

* Invoke the Validation sequence and run hooks * - Before Validation Model Hooks * - Validation * - On validation success: After Validation Model Hooks * - On validation failure: Validation Failed Model Hooks * * @returns {Promise} * @private

()

Source from the content-addressed store, hash-verified

104 * @private
105 */
106 async _validateAndRunHooks() {
107 const runHooks = this.modelInstance.constructor.runHooks.bind(this.modelInstance.constructor);
108 await runHooks(class="st">'beforeValidate', this.modelInstance, this.options);
109
110 try {
111 await this._validate();
112 } catch (error) {
113 const newError = await runHooks(class="st">'validationFailed', this.modelInstance, this.options, error);
114 throw newError || error;
115 }
116
117 await runHooks(class="st">'afterValidate', this.modelInstance, this.options);
118 return this.modelInstance;
119 }
120
121 /**
122 * Will run all the validators defined per attribute (built-in validators and custom validators)

Callers 2

validateMethod · 0.95

Calls 2

_validateMethod · 0.95
runHooksFunction · 0.85

Tested by

no test coverage detected