1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-24 22:10:54 +00:00

Handle pointer validation

This commit is contained in:
Andrea Spacca 2018-01-28 17:40:05 +01:00
parent f16688817a
commit ee9cf05796

View File

@ -245,7 +245,17 @@ func (v *Validation) ZipCode(obj interface{}, key string) *Result {
}
func (v *Validation) apply(chk Validator, obj interface{}) *Result {
if chk.IsSatisfied(obj) {
if reflect.TypeOf(obj).Kind() == reflect.Ptr {
if reflect.ValueOf(obj).IsNil() {
if "Required" != chk.GetKey() {
return &Result{Ok: true}
}
} else {
if chk.IsSatisfied(reflect.ValueOf(obj).Elem().Interface()) {
return &Result{Ok: true}
}
}
} else if chk.IsSatisfied(obj) {
return &Result{Ok: true}
}