Skip to content

Commit 052c7d1

Browse files
authored
Update request.md (#171)
1 parent c69839b commit 052c7d1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

website/content/guide/request.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,18 @@ type (
179179
)
180180

181181
func (cv *CustomValidator) Validate(i interface{}) error {
182-
return echo.NewHTTPError(http.StatusInternalServerError, cv.validator.Struct(i).Error())
182+
return cv.validator.Struct(i)
183183
}
184184

185185
func main() {
186186
e := echo.New()
187187
e.Validator = &CustomValidator{validator: validator.New()}
188188
e.POST("/users", func(c echo.Context) (err error) {
189189
u := new(User)
190-
if err = c.Bind(u); err != nil {
190+
if err := c.Bind(u); err != nil {
191191
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
192192
}
193-
if err = c.Validate(u); err != nil {
193+
if err := c.Validate(u); err != nil {
194194
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
195195
}
196196
return c.JSON(http.StatusOK, u)

0 commit comments

Comments
 (0)