mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-18 23:12:17 +08:00
opt switch branchs in ValidateStruct()
This commit is contained in:
parent
03ce1a6b86
commit
023a72b783
@ -40,12 +40,9 @@ func (v *defaultValidator) ValidateStruct(obj interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
value := reflect.ValueOf(obj)
|
value := reflect.ValueOf(obj)
|
||||||
valueType := value.Kind()
|
switch value.Kind() {
|
||||||
if valueType == reflect.Ptr {
|
case reflect.Ptr:
|
||||||
return v.ValidateStruct(value.Elem().Interface())
|
return v.ValidateStruct(value.Elem().Interface())
|
||||||
}
|
|
||||||
|
|
||||||
switch valueType {
|
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
return v.validateStruct(obj)
|
return v.validateStruct(obj)
|
||||||
case reflect.Slice, reflect.Array:
|
case reflect.Slice, reflect.Array:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user