MCPcopy
hub / github.com/sequelize/sequelize / validate

Method validate

lib/dialects/abstract/query-generator.js:1071–1096  ·  lib/dialects/abstract/query-generator.js::QueryGenerator.validate
(value, field, options)

Source from the content-addressed store, hash-verified

1069 @private
1070 */
1071 validate(value, field, options) {
1072 if (this.typeValidation && field.type.validate && value) {
1073 try {
1074 if (options.isList && Array.isArray(value)) {
1075 for (const item of value) {
1076 field.type.validate(item, options);
1077 }
1078 } else {
1079 field.type.validate(value, options);
1080 }
1081 } catch (error) {
1082 if (error instanceof sequelizeError.ValidationError) {
1083 error.errors.push(new sequelizeError.ValidationErrorItem(
1084 error.message,
1085 class="st">'Validation error',
1086 field.fieldName,
1087 value,
1088 null,
1089 `${field.type.key} validator`
1090 ));
1091 }
1092
1093 throw error;
1094 }
1095 }
1096 }
1097
1098 isIdentifierQuoted(identifier) {
1099 return /^\s*(?:([`"'])(?:(?!\1).|\1{2})*\1\.?)+\s*$/i.test(identifier);

Callers 2

escapeMethod · 0.95
formatMethod · 0.95

Calls 1

validateMethod · 0.65

Tested by

no test coverage detected