Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
    }