Skip to content

Commit

Permalink
opt switch branchs in ValidateStruct()
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhuizuo committed Apr 13, 2020
1 parent 03ce1a6 commit 023a72b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions binding/default_validator.go
Expand Up @@ -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:
Expand Down

0 comments on commit 023a72b

Please sign in to comment.