opt switch branchs in ValidateStruct()

This commit is contained in:
wuhuizuo 2020-04-13 04:19:28 +00:00
parent 03ce1a6b86
commit 023a72b783

View File

@ -40,12 +40,9 @@ func (v *defaultValidator) ValidateStruct(obj interface{}) error {
}
value := reflect.ValueOf(obj)
valueType := value.Kind()
if valueType == reflect.Ptr {
switch value.Kind() {
case reflect.Ptr:
return v.ValidateStruct(value.Elem().Interface())
}
switch valueType {
case reflect.Struct:
return v.validateStruct(obj)
case reflect.Slice, reflect.Array: