| 1192 | @private |
| 1193 | */ |
| 1194 | validate(value, field, options) { |
| 1195 | if (this.typeValidation && field.type.validate && value) { |
| 1196 | try { |
| 1197 | if (options.isList && Array.isArray(value)) { |
| 1198 | for (const item of value) { |
| 1199 | field.type.validate(item, options); |
| 1200 | } |
| 1201 | } else { |
| 1202 | field.type.validate(value, options); |
| 1203 | } |
| 1204 | } catch (error) { |
| 1205 | if (error instanceof sequelizeError.ValidationError) { |
| 1206 | error.errors.push(new sequelizeError.ValidationErrorItem( |
| 1207 | error.message, |
| 1208 | 'Validation error', |
| 1209 | field.fieldName, |
| 1210 | value, |
| 1211 | null, |
| 1212 | `${field.type.key} validator` |
| 1213 | )); |
| 1214 | } |
| 1215 | |
| 1216 | throw error; |
| 1217 | } |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | isIdentifierQuoted(identifier) { |
| 1222 | return /^\s*(?:([`"'])(?:(?!\1).|\1{2})*\1\.?)+\s*$/i.test(identifier); |