mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 21:28:22 +08:00
28 lines
862 B
Go
28 lines
862 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gogf/gf/g/util/gvalid"
|
|
)
|
|
|
|
func main() {
|
|
params := map[string]interface{} {
|
|
"passport" : "",
|
|
"password" : "123456",
|
|
"password2" : "1234567",
|
|
}
|
|
rules := []string {
|
|
"passport@required|length:6,16#账号不能为空|账号长度应当在:min到:max之间",
|
|
"password@required|length:6,16|same:password2#密码不能为空}|两次密码输入不相等",
|
|
"password2@required|length:6,16#",
|
|
}
|
|
if e := gvalid.CheckMap(params, rules); e != nil {
|
|
fmt.Println(e.Map())
|
|
fmt.Println(e.FirstItem())
|
|
fmt.Println(e.FirstString())
|
|
}
|
|
// map[required:账号不能为空 length:账号长度应当在6到16之间]
|
|
// passport map[required:账号不能为空 length:账号长度应当在6到16之间]
|
|
// 账号不能为空
|
|
}
|