mirror of https://github.com/gin-gonic/gin.git
Add validating sub structures
This commit is contained in:
parent
28b9ff9e34
commit
f145e435c7
|
@ -199,6 +199,17 @@ func Validate(obj interface{}, parents ...string) error {
|
|||
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:
|
||||
|
|
Loading…
Reference in New Issue