Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions translations/zh/zh.go
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,11 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return t
},
},
{
tag: "unique",
translation: "{0}必须包含唯一值",
override: false,
},
{
tag: "image",
translation: "{0} 必须是有效图像",
Expand Down
7 changes: 7 additions & 0 deletions translations/zh/zh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func TestTranslations(t *testing.T) {
UppercaseString string `validate:"uppercase"`
Datetime string `validate:"datetime=2006-01-02"`
Image string `validate:"image"`
UniqueSlice []string `validate:"unique"`
}

var test Test
Expand Down Expand Up @@ -247,6 +248,8 @@ func TestTranslations(t *testing.T) {

test.Datetime = "20060102"

test.UniqueSlice = []string{"1234", "1234"}

err = validate.Struct(test)
NotEqual(t, err, nil)

Expand Down Expand Up @@ -769,6 +772,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.Image",
expected: "Image 必须是有效图像",
},
{
ns: "Test.UniqueSlice",
expected: "UniqueSlice必须包含唯一值",
},
}

for _, tt := range tests {
Expand Down
5 changes: 5 additions & 0 deletions translations/zh_tw/zh_tw.go
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,11 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return t
},
},
{
tag: "unique",
translation: "{0}必須包含唯一值",
override: false,
},
{
tag: "image",
translation: "{0} 必須是有效圖像",
Expand Down
7 changes: 7 additions & 0 deletions translations/zh_tw/zh_tw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func TestTranslations(t *testing.T) {
OneOfInt int `validate:"oneof=5 63"`
Datetime string `validate:"datetime=2006-01-02"`
Image string `validate:"image"`
UniqueSlice []string `validate:"unique"`
}

var test Test
Expand Down Expand Up @@ -229,6 +230,8 @@ func TestTranslations(t *testing.T) {

test.Datetime = "2008-Feb-01"

test.UniqueSlice = []string{"1234", "1234"}

err = validate.Struct(test)
NotEqual(t, err, nil)

Expand Down Expand Up @@ -719,6 +722,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.Image",
expected: "Image 必須是有效圖像",
},
{
ns: "Test.UniqueSlice",
expected: "UniqueSlice必須包含唯一值",
},
}

for _, tt := range tests {
Expand Down