github.com/wangyougui/gf/v2@v2.6.5/util/gvalid/gvalid_z_unit_feature_ci_test.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/wangyougui/gf.
     6  
     7  package gvalid_test
     8  
     9  import (
    10  	"testing"
    11  
    12  	"github.com/wangyougui/gf/v2/frame/g"
    13  	"github.com/wangyougui/gf/v2/test/gtest"
    14  )
    15  
    16  func Test_CI(t *testing.T) {
    17  	gtest.C(t, func(t *gtest.T) {
    18  		err := g.Validator().Data("id").Rules("in:Id,Name").Run(ctx)
    19  		t.AssertNE(err, nil)
    20  	})
    21  	gtest.C(t, func(t *gtest.T) {
    22  		err := g.Validator().Data("id").Rules("ci|in:Id,Name").Run(ctx)
    23  		t.AssertNil(err)
    24  	})
    25  	gtest.C(t, func(t *gtest.T) {
    26  		err := g.Validator().Ci().Rules("in:Id,Name").Data("id").Run(ctx)
    27  		t.AssertNil(err)
    28  	})
    29  }