Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support binding for slice/array obj [Rewrite] #2302

Merged
Prev Previous commit
Next Next commit
opt switch branchs in ValidateStruct()
  • Loading branch information
wuhuizuo committed Apr 13, 2020
commit 023a72b7833744155528b3e3264b9bc33b1b7532
7 changes: 2 additions & 5 deletions binding/default_validator.go
Original file line number Diff line number Diff line change
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