Skip to content

Commit

Permalink
improve test to account for map order randomness
Browse files Browse the repository at this point in the history
  • Loading branch information
OscarVanL committed Aug 25, 2022
1 parent b65b3a4 commit 0750547
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func (d *StructData) loadMessagesFromTag(trans *Translator, field, vRule, vMsg s

if vName == "" {
// eg `validate:"required|date"`
vNames = append(vNames, vRule)
vNames = []string{vRule}

if strings.ContainsRune(vRule, '|') {
vNames = strings.Split(vRule, "|")
Expand Down
4 changes: 3 additions & 1 deletion messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ func TestMessageOnStruct(t *testing.T) {
v = Struct(s5)

is.False(v.Validate())
is.Equal("BirthDay:\n max_len: 出生日期有误\n date: 出生日期有误", v.Errors.String())
is.Contains(v.Errors.String(), "BirthDay")
is.Contains(v.Errors.String(), "max_len: 出生日期有误")
is.Contains(v.Errors.String(), "date: 出生日期有误")

// Restore original global options
Config(func(opt *GlobalOption) {
Expand Down

0 comments on commit 0750547

Please sign in to comment.