[go-server] add field name in parsing error messages (#18533)

Currently when a parsing rule of a field is not respected (eg: min/max
value, required, ...), the api only returns an  error message without
providing the field name to help the user to fix the request. This commit
add the field name to the error message to help the user of the API.
This commit is contained in:
rledisez
2024-05-01 07:28:51 -04:00
committed by GitHub
parent 10897caf37
commit 230e8ce887
15 changed files with 112 additions and 92 deletions

View File

@@ -190,7 +190,7 @@ func (c *UserAPIController) DeleteUser(w http.ResponseWriter, r *http.Request) {
WithParse[bool](parseBool),
)
if err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
c.errorHandler(w, r, &ParsingError{Param: "boolean_test", Err: err}, nil)
return
}
@@ -256,7 +256,7 @@ func (c *UserAPIController) LoginUser(w http.ResponseWriter, r *http.Request) {
WithParse[bool](parseBool),
)
if err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
c.errorHandler(w, r, &ParsingError{Param: "boolean_test", Err: err}, nil)
return
}