"gvalid length" compatible with only one parameter

This commit is contained in:
wanna
2021-05-28 11:34:51 +08:00
parent 5100e0e8b7
commit b2d3c7d1fd
2 changed files with 13 additions and 0 deletions

View File

@ -658,6 +658,17 @@ func Test_Length(t *testing.T) {
if m := gvalid.CheckValue(context.TODO(), "12345", rule, nil); m == nil {
t.Error("长度校验失败")
}
// only one parameter
rule2 := "length:5"
if m := gvalid.CheckValue(context.TODO(), "1234", rule2, nil); m == nil {
t.Error(m)
}
if m := gvalid.CheckValue(context.TODO(), "12345", rule2, nil); m != nil {
t.Error(m)
}
if m := gvalid.CheckValue(context.TODO(), "123456", rule2, nil); m == nil {
t.Error("长度校验失败")
}
}
func Test_MinLength(t *testing.T) {