correct FieldError error printing idea issue

for #78
pull/82/head
joeybloggs 10 years ago
parent 6eded1f817
commit 1ba858eec1
  1. 20
      validator.go

@ -173,27 +173,14 @@ func (e *FieldError) Error() string {
if e.IsSliceOrArray { if e.IsSliceOrArray {
for i, err := range e.SliceOrArrayErrs { for j, err := range e.SliceOrArrayErrs {
buff.WriteString(fmt.Sprintf(sliceErrMsg, e.Field, j, "\n"+err.Error()))
if i != 0 {
buff.WriteString("\n")
}
buff.WriteString(fmt.Sprintf(sliceErrMsg, e.Field, i, err))
} }
} else if e.IsMap { } else if e.IsMap {
var i uint64
for key, err := range e.MapErrs { for key, err := range e.MapErrs {
buff.WriteString(fmt.Sprintf(mapErrMsg, e.Field, key, "\n"+err.Error()))
if i != 0 {
buff.WriteString("\n")
}
buff.WriteString(fmt.Sprintf(mapErrMsg, e.Field, key, err))
i++
} }
} }
@ -233,7 +220,6 @@ func (e *StructErrors) Error() string {
} }
buff.WriteString(err.Error()) buff.WriteString(err.Error())
i++ i++
} }

Loading…
Cancel
Save