func AddErrorForColumn(db *gorm.DB, resource interface{}, column, err string) { var validationErrors = GetErrors(db) var scope = db.NewScope(resource) key := fmt.Sprintf("%v_%v_%v", scope.GetModelStruct().ModelType.Name(), scope.PrimaryKeyValue(), column) validationErrors[key] = append(validationErrors[key], err) db.InstantSet(settingKey, validationErrors).Error = fmt.Errorf("RecordInvalid: %v", err) }