25 lines
459 B
Go
25 lines
459 B
Go
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
|
|
}
|