⬆️ Upgrade Passport and use Hyper SDK

This commit is contained in:
2024-06-22 12:29:20 +08:00
parent b951cd2696
commit 72299c810b
13 changed files with 137 additions and 172 deletions

View File

@@ -0,0 +1,18 @@
package exts
import (
"github.com/go-playground/validator/v10"
"github.com/gofiber/fiber/v2"
)
var validation = validator.New(validator.WithRequiredStructEnabled())
func BindAndValidate(c *fiber.Ctx, out any) error {
if err := c.BodyParser(out); err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error())
} else if err := validation.Struct(out); err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error())
}
return nil
}