mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
improve package gvalid
This commit is contained in:
2
os/gres/testdata/data/data.go
vendored
2
os/gres/testdata/data/data.go
vendored
File diff suppressed because one or more lines are too long
2
os/gres/testdata/testdata.go
vendored
2
os/gres/testdata/testdata.go
vendored
File diff suppressed because one or more lines are too long
@ -148,7 +148,7 @@ func (e *validationError) FirstRule() (rule string, err string) {
|
||||
array := strings.Split(ruleItem, ":")
|
||||
ruleItem = strings.TrimSpace(array[0])
|
||||
if err, ok = errorItemMap[ruleItem]; ok {
|
||||
return ruleStr, err
|
||||
return ruleItem, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,6 +191,11 @@ func Test_Sequence(t *testing.T) {
|
||||
t.Assert(err.Map()["length"], "账号长度应当在6到16之间")
|
||||
t.Assert(len(err.Maps()), 2)
|
||||
|
||||
t.Assert(len(err.Items()), 2)
|
||||
t.Assert(err.Items()[0]["passport"]["length"], "账号长度应当在6到16之间")
|
||||
t.Assert(err.Items()[0]["passport"]["required"], "账号不能为空")
|
||||
t.Assert(err.Items()[1]["password"]["same"], "两次密码输入不相等")
|
||||
|
||||
t.Assert(err.String(), "账号不能为空; 账号长度应当在6到16之间; 两次密码输入不相等")
|
||||
t.Assert(err.Strings(), []string{"账号不能为空", "账号长度应当在6到16之间", "两次密码输入不相等"})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user