Fix validation errors formatter

This commit is contained in:
ErickSkrauch 2024-06-10 20:52:45 +02:00
parent ce6e62ae5c
commit 62b6ac8083
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E

View File

@ -75,12 +75,12 @@ func (p *ProfilesApi) postProfileHandler(resp http.ResponseWriter, req *http.Req
// Manager returns ValidationError according to the struct fields names. // Manager returns ValidationError according to the struct fields names.
// They are uppercased, but otherwise the same as the names in the API. // They are uppercased, but otherwise the same as the names in the API.
// So to make them consistent it's enough just to make the first lowercased. // So to make them consistent it's enough just to make the first lowercased.
newErrors := make(map[string][]string, len(v.Errors))
for field, errors := range v.Errors { for field, errors := range v.Errors {
v.Errors[xstrings.FirstRuneToLower(field)] = errors newErrors[xstrings.FirstRuneToLower(field)] = errors
delete(v.Errors, field)
} }
apiBadRequest(resp, v.Errors) apiBadRequest(resp, newErrors)
return return
} }