chore: update userinfo validator (#868)

* chore: update userinfo validator

* chore: update actions

* chore: update
This commit is contained in:
boojack
2022-12-27 21:51:43 +08:00
committed by GitHub
parent c160bed403
commit f888c62840
6 changed files with 90 additions and 9 deletions

View File

@ -198,9 +198,8 @@ func (s *Server) registerUserRoutes(g *echo.Group) {
if err := json.NewDecoder(c.Request().Body).Decode(userPatch); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Malformatted patch user request").SetInternal(err)
}
if userPatch.Email != nil && *userPatch.Email != "" && !common.ValidateEmail(*userPatch.Email) {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid email format")
if err := userPatch.Validate(); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid user patch format.").SetInternal(err)
}
if userPatch.Password != nil && *userPatch.Password != "" {