2018-08-31 00:07:48 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-07-29 21:01:19 +08:00
|
|
|
"github.com/gogf/gf/frame/g"
|
|
|
|
"github.com/gogf/gf/util/gvalid"
|
2018-08-31 00:07:48 +08:00
|
|
|
)
|
|
|
|
|
2018-11-13 00:12:35 +08:00
|
|
|
// 返回结果方法示例
|
2018-08-31 00:07:48 +08:00
|
|
|
func main() {
|
2019-04-03 00:03:46 +08:00
|
|
|
type User struct {
|
|
|
|
Password string `gvalid:"password@password"`
|
|
|
|
ConfiemPassword string `gvalid:"confirm_password@password|same:password#|密码与确认密码不一致"`
|
|
|
|
}
|
2018-08-31 00:07:48 +08:00
|
|
|
|
2019-04-03 00:03:46 +08:00
|
|
|
user := &User{
|
|
|
|
Password: "123456",
|
|
|
|
ConfiemPassword: "",
|
|
|
|
}
|
2018-08-31 00:07:48 +08:00
|
|
|
|
2019-04-03 00:03:46 +08:00
|
|
|
e := gvalid.CheckStruct(user, nil)
|
|
|
|
g.Dump(e.Map())
|
|
|
|
g.Dump(e.Maps())
|
|
|
|
g.Dump(e.String())
|
|
|
|
g.Dump(e.Strings())
|
|
|
|
g.Dump(e.FirstItem())
|
|
|
|
g.Dump(e.FirstRule())
|
|
|
|
g.Dump(e.FirstString())
|
2018-08-31 00:07:48 +08:00
|
|
|
}
|