* 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
()
| 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) |
no test coverage detected