2018-08-30 23:48:22 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2019-04-03 00:03:46 +08:00
|
|
|
"github.com/gogf/gf/g"
|
|
|
|
|
"github.com/gogf/gf/g/util/gvalid"
|
2018-08-30 23:48:22 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// same校验
|
|
|
|
|
func main() {
|
2019-04-03 00:03:46 +08:00
|
|
|
type User struct {
|
|
|
|
|
Password string `gvalid:"password@password"`
|
|
|
|
|
ConfirmPassword string `gvalid:"confirm_password@password|same:password#|密码与确认密码不一致"`
|
|
|
|
|
}
|
2018-08-30 23:48:22 +08:00
|
|
|
|
2019-04-03 00:03:46 +08:00
|
|
|
user := &User{
|
|
|
|
|
Password: "123456",
|
|
|
|
|
ConfirmPassword: "",
|
|
|
|
|
}
|
2018-08-30 23:48:22 +08:00
|
|
|
|
2019-04-03 00:03:46 +08:00
|
|
|
g.Dump(gvalid.CheckStruct(user, nil))
|
2018-08-30 23:48:22 +08:00
|
|
|
}
|