2021-11-22 14:41:33 +08:00
|
|
|
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
|
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
|
|
|
|
|
|
package gvalid_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
|
|
|
"github.com/gogf/gf/v2/test/gtest"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Test_CI(t *testing.T) {
|
|
|
|
|
gtest.C(t, func(t *gtest.T) {
|
2021-12-04 00:11:57 +08:00
|
|
|
err := g.Validator().Data("id").Rules("in:Id,Name").Run(ctx)
|
2021-11-22 14:41:33 +08:00
|
|
|
t.AssertNE(err, nil)
|
|
|
|
|
})
|
|
|
|
|
gtest.C(t, func(t *gtest.T) {
|
2021-12-04 00:11:57 +08:00
|
|
|
err := g.Validator().Data("id").Rules("ci|in:Id,Name").Run(ctx)
|
2021-11-22 14:41:33 +08:00
|
|
|
t.AssertNil(err)
|
|
|
|
|
})
|
|
|
|
|
gtest.C(t, func(t *gtest.T) {
|
2021-11-23 10:42:43 +08:00
|
|
|
err := g.Validator().Ci().Rules("in:Id,Name").Data("id").Run(ctx)
|
2021-11-22 14:41:33 +08:00
|
|
|
t.AssertNil(err)
|
|
|
|
|
})
|
|
|
|
|
}
|