MCPcopy
hub / github.com/sequelize/sequelize / _perAttributeValidators

Method _perAttributeValidators

lib/instance-validator.js:127–153  ·  lib/instance-validator.js::InstanceValidator._perAttributeValidators

* Will run all the validators defined per attribute (built-in validators and custom validators) * * @returns {Promise<Array>} * @private

()

Source from the content-addressed store, hash-verified

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.

Callers 1

_validateMethod · 0.95

Calls 3

_validateSchemaMethod · 0.95
_singleAttrValidateMethod · 0.95
allMethod · 0.80

Tested by

no test coverage detected