@@ -27,7 +27,7 @@ func (e *InvalidParamsError) Add(err InvalidParamError) {
27
27
// updated and base context to reflect the merging.
28
28
//
29
29
// Use for nested validations errors.
30
- func (e * InvalidParamsError ) AddNested (nestedCtx string , nested * InvalidParamsError ) {
30
+ func (e * InvalidParamsError ) AddNested (nestedCtx string , nested InvalidParamsError ) {
31
31
for _ , err := range nested .errs {
32
32
err .SetContext (e .Context )
33
33
err .AddNestedContext (nestedCtx )
@@ -41,7 +41,7 @@ func (e *InvalidParamsError) Len() int {
41
41
}
42
42
43
43
// Error returns the string formatted form of the invalid parameters.
44
- func (e * InvalidParamsError ) Error () string {
44
+ func (e InvalidParamsError ) Error () string {
45
45
w := & bytes.Buffer {}
46
46
fmt .Fprintf (w , "%d validation error(s) found.\n " , len (e .errs ))
47
47
@@ -53,7 +53,7 @@ func (e *InvalidParamsError) Error() string {
53
53
}
54
54
55
55
// Errs returns a slice of the invalid parameters
56
- func (e * InvalidParamsError ) Errs () []error {
56
+ func (e InvalidParamsError ) Errs () []error {
57
57
errs := make ([]error , len (e .errs ))
58
58
for i := 0 ; i < len (errs ); i ++ {
59
59
errs [i ] = e .errs [i ]
@@ -84,16 +84,18 @@ type invalidParamError struct {
84
84
}
85
85
86
86
// Error returns the string version of the invalid parameter error.
87
- func (e * invalidParamError ) Error () string {
87
+ func (e invalidParamError ) Error () string {
88
88
return fmt .Sprintf ("%s, %s." , e .reason , e .Field ())
89
89
}
90
90
91
91
// Field Returns the field and context the error occurred.
92
- func (e * invalidParamError ) Field () string {
92
+ func (e invalidParamError ) Field () string {
93
93
sb := & strings.Builder {}
94
- sb .WriteString (e .field )
94
+ sb .WriteString (e .context )
95
95
if sb .Len () > 0 {
96
- sb .WriteRune ('.' )
96
+ if len (e .nestedContext ) == 0 || (len (e .nestedContext ) > 0 && e .nestedContext [:1 ] != "[" ) {
97
+ sb .WriteRune ('.' )
98
+ }
97
99
}
98
100
if len (e .nestedContext ) > 0 {
99
101
sb .WriteString (e .nestedContext )
0 commit comments