Export struct sliceValidateError to allow error casting and rename it as (#2777)

SliceValidationError

Co-authored-by: Emeric de Bernis <emeric.debernis@adevinta.com>
This commit is contained in:
edebernis
2021-11-21 14:45:03 +01:00
committed by GitHub
parent 6aee45608d
commit 57ede9c95a
3 changed files with 14 additions and 14 deletions
+4 -4
View File
@@ -18,10 +18,10 @@ type defaultValidator struct {
validate *validator.Validate
}
type sliceValidateError []error
type SliceValidationError []error
// Error concatenates all error elements in sliceValidateError into a single string separated by \n.
func (err sliceValidateError) Error() string {
// Error concatenates all error elements in SliceValidationError into a single string separated by \n.
func (err SliceValidationError) Error() string {
n := len(err)
switch n {
case 0:
@@ -59,7 +59,7 @@ func (v *defaultValidator) ValidateStruct(obj interface{}) error {
return v.validateStruct(obj)
case reflect.Slice, reflect.Array:
count := value.Len()
validateRet := make(sliceValidateError, 0)
validateRet := make(SliceValidationError, 0)
for i := 0; i < count; i++ {
if err := v.ValidateStruct(value.Index(i).Interface()); err != nil {
validateRet = append(validateRet, err)