* Will run all the validators defined per attribute (built-in validators and custom validators) * * @returns {Promise<Array>} * @private
()
| 125 | * @private |
| 126 | */ |
| 127 | async _perAttributeValidators() { |
| 128 | class="cm">// promisify all attribute invocations |
| 129 | const validators = []; |
| 130 | |
| 131 | _.forIn(this.modelInstance.rawAttributes, (rawAttribute, field) => { |
| 132 | if (this.options.skip.includes(field)) { |
| 133 | return; |
| 134 | } |
| 135 | |
| 136 | const value = this.modelInstance.dataValues[field]; |
| 137 | |
| 138 | if (value instanceof Utils.SequelizeMethod) { |
| 139 | return; |
| 140 | } |
| 141 | |
| 142 | if (!rawAttribute._autoGenerated && !rawAttribute.autoIncrement) { |
| 143 | class="cm">// perform validations based on schema |
| 144 | this._validateSchema(rawAttribute, field, value); |
| 145 | } |
| 146 | |
| 147 | if (Object.prototype.hasOwnProperty.call(this.modelInstance.validators, field)) { |
| 148 | validators.push(this._singleAttrValidate(value, field, rawAttribute.allowNull)); |
| 149 | } |
| 150 | }); |
| 151 | |
| 152 | return await Promise.all(validators); |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Will run all the custom validators defined in the model's options. |
no test coverage detected