add validator
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"astra-events/model"
|
||||
"astra-events/pkg/utils"
|
||||
"astra-events/services"
|
||||
"fmt"
|
||||
"github.com/google/uuid"
|
||||
"github.com/hashicorp/go-set"
|
||||
"github.com/labstack/echo/v4"
|
||||
@@ -19,8 +20,11 @@ func (h *Handler) CreateEvent(c echo.Context) (err error) {
|
||||
return c.NoContent(http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
if err = c.Bind(event); err != nil {
|
||||
return c.NoContent(http.StatusBadRequest)
|
||||
err = c.Bind(&event)
|
||||
err = h.Validator.Struct(event)
|
||||
|
||||
if err != nil {
|
||||
return c.HTML(http.StatusBadRequest, fmt.Sprintf("Err(s):\n%+v\n", err))
|
||||
}
|
||||
|
||||
if event.Person.ID.ID() != 0 {
|
||||
|
||||
Reference in New Issue
Block a user