gdb.Value增加IsNil方法

This commit is contained in:
john
2018-08-31 10:01:31 +08:00
parent d0a94674ad
commit a6ff5bd467
2 changed files with 3 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import (
"gitee.com/johng/gf/g/util/gconv"
)
func (v Value) IsNil() bool { return v == nil }
func (v Value) Bytes() []byte { return []byte(v) }
func (v Value) String() string { return string(v.Bytes()) }
func (v Value) Bool() bool { return gconv.Bool(v.Bytes()) }

View File

@ -10,12 +10,12 @@ import (
func main() {
type User struct {
Password string `gvalid:"password@password"`
ConfiemPassword string `gvalid:"confirm_password@password|same:password#|密码与确认密码不一致"`
ConfirmPassword string `gvalid:"confirm_password@password|same:password#|密码与确认密码不一致"`
}
user := &User{
Password : "123456",
ConfiemPassword : "",
ConfirmPassword : "",
}
gutil.Dump(gvalid.CheckStruct(user, nil))