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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user