Skip to content

Commit

Permalink
duplicate validator
Browse files Browse the repository at this point in the history
  • Loading branch information
iesreza committed Jun 11, 2024
1 parent e7434da commit 786dbce
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/validation/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func uniqueValidator(match []string, value *generic.Value, stmt *gorm.Statement,
}
of, zero := stmt.Schema.PrioritizedPrimaryField.ValueOf(context.Background(), reflect.ValueOf(stmt.Model))
var c int64
//TODO: check for unique index
var model = db.Table(stmt.Table).Where(field.DBName+" = ?", value.Input)
if !zero {
model = model.Where(stmt.Schema.PrioritizedPrimaryField.DBName+" != ?", of)
Expand Down

0 comments on commit 786dbce

Please sign in to comment.