refactor/fix: now using pgx errors for postgres error checking instead of trying to look up the error code;

feat: implemented working custom validation;
fix: authservice begin/complete registration
This commit is contained in:
2025-07-05 03:08:00 +03:00
parent 0a51727af8
commit 8319afc7ea
9 changed files with 126 additions and 39 deletions

View File

@@ -19,9 +19,12 @@ package middleware
import (
"easywish/internal/utils/enums"
"easywish/internal/validation"
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
)
type UserInfo struct {
@@ -87,6 +90,15 @@ func RequestMiddleware[T any](role enums.Role) gin.HandlerFunc {
return
}
validate := validation.NewValidator()
if err := validate.Struct(body); err != nil {
errorList := err.(validator.ValidationErrors)
c.String(http.StatusBadRequest, fmt.Sprintf("Validation error: %s", errorList))
return
}
request := Request[T]{
User: *userInfo,
Body: body,