From 62b6ac8083d92728a286eabc193b7cbfcc5272de Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Mon, 10 Jun 2024 20:52:45 +0200 Subject: [PATCH] Fix validation errors formatter --- internal/http/profiles.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/http/profiles.go b/internal/http/profiles.go index 04bf2cc..ba7033e 100644 --- a/internal/http/profiles.go +++ b/internal/http/profiles.go @@ -75,12 +75,12 @@ func (p *ProfilesApi) postProfileHandler(resp http.ResponseWriter, req *http.Req // Manager returns ValidationError according to the struct fields names. // 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. + newErrors := make(map[string][]string, len(v.Errors)) for field, errors := range v.Errors { - v.Errors[xstrings.FirstRuneToLower(field)] = errors - delete(v.Errors, field) + newErrors[xstrings.FirstRuneToLower(field)] = errors } - apiBadRequest(resp, v.Errors) + apiBadRequest(resp, newErrors) return }