...
https://godoc.org/github.com/gogf/gf/text/gstr
AddSlashes
- 格式:
different:field
- 说明:参数值不能与
field
参数的值相同 - 示例:备用邮箱
OtherMailAddr
和邮箱地址MailAddr
必须不相同func ExampleValidator_Different() { type BizReq struct { Name string `v:"required"` MailAddr string `v:"required"` OtherMailAddr string `v:"required|different:MailAddr"` } var ( ctx = context.Background() req = BizReq{ Name: "gf", MailAddr: "gf@goframe.org", OtherMailAddr: "gf@goframe.org", } ) if err := g.Validator().CheckStruct(ctx, req); err != nil { fmt.Println(err) } // Output: // The OtherMailAddr value must be different from field MailAddr }