github.com/gogf/gf@v1.16.9/.example/util/gvalid/gvalid_struct3.go (about) 1 package main 2 3 import ( 4 "context" 5 "github.com/gogf/gf/frame/g" 6 "github.com/gogf/gf/util/gvalid" 7 ) 8 9 // same校验 10 func main() { 11 type User struct { 12 Pass string `gvalid:"passwd1 @required|length:2,20|password3||密码强度不足"` 13 } 14 15 user := &User{ 16 Pass: "1", 17 } 18 19 g.Dump(gvalid.CheckStruct(context.TODO(), user, nil).Maps()) 20 }