In Go+Echo's validation check, I want to display an error message even if there is a type error
19:06 20 Dec 2023

The following processing is performed using Go + Echo + play-ground/validator.


if err := c.Bind(&user); err != nil {
    return err
}

err := c.Validate(user)

if err != nil {
    return c.Render(http.StatusOK, "user_form.html", err)
}

If there is a type error, an error will occur in c.Bind and it will not proceed to c.Validate. Also, if an error occurs with c.Bind, it is not possible to identify the field that caused the error.

I would like to display type errors in c.Bind and mandatory checks in c.Validate in the same screen, but is there a good way to write them?

I looked for some other stack overflow posts but couldn't find a good answer.

go