diff --git a/callbacks.go b/callbacks.go index 3c63d06..394073e 100644 --- a/callbacks.go +++ b/callbacks.go @@ -70,6 +70,10 @@ func formattedError(err govalidator.Error, resource interface{}) error { // RegisterCallbacks register callback into GORM DB func RegisterCallbacks(db *gorm.DB) { callback := db.Callback() - callback.Create().Before("gorm:before_create").Register("validations:validate", validate) - callback.Update().Before("gorm:before_update").Register("validations:validate", validate) + if callback.Create().Get("validations:validate") == nil { + callback.Create().Before("gorm:before_create").Register("validations:validate", validate) + } + if callback.Update().Get("validations:validate") == nil { + callback.Update().Before("gorm:before_update").Register("validations:validate", validate) + } }