mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 02:20:53 +00:00
Handle pointer validation
This commit is contained in:
parent
f16688817a
commit
ee9cf05796
@ -245,7 +245,17 @@ func (v *Validation) ZipCode(obj interface{}, key string) *Result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *Validation) apply(chk Validator, obj interface{}) *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}
|
return &Result{Ok: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user