Add validating sub structures

This commit is contained in:
Evgeny Persienko 2015-02-20 11:37:20 +06:00
parent 28b9ff9e34
commit f145e435c7

View File

@ -199,6 +199,17 @@ func Validate(obj interface{}, parents ...string) error {
return err return err
} }
} }
} else {
fieldType := field.Type.Kind()
if fieldType == reflect.Struct {
if reflect.DeepEqual(zero, fieldValue) {
continue
}
err := Validate(fieldValue, field.Name)
if err != nil {
return err
}
}
} }
} }
case reflect.Slice: case reflect.Slice: