Base Project

This commit is contained in:
Tran Anh Tuan
2026-05-08 14:32:24 +07:00
parent 5a9249c9ea
commit 6a4a96e0ca
74 changed files with 6749 additions and 0 deletions

24
pkg/helper/validator.go Normal file
View File

@@ -0,0 +1,24 @@
package helper
import (
"net/http"
"wm-backend/response"
"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
)
func IsShouldBindJSON(c *gin.Context, obj any) bool {
if err := c.ShouldBindJSON(obj); err != nil {
response.BadRequestError(c, http.StatusBadRequest, err.Error())
return true
}
return false
}
var validate = validator.New()
func IsEmail(input string) bool {
err := validate.Var(input, "email")
return err == nil
}