|
|
@ -4,9 +4,9 @@ import ( |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
. "github.com/go-playground/assert/v2" |
|
|
|
english "github.com/go-playground/locales/en" |
|
|
|
english "github.com/go-playground/locales/en" |
|
|
|
ut "github.com/go-playground/universal-translator" |
|
|
|
ut "github.com/go-playground/universal-translator" |
|
|
|
. "github.com/go-playground/assert/v2" |
|
|
|
|
|
|
|
"github.com/go-playground/validator/v10" |
|
|
|
"github.com/go-playground/validator/v10" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -141,6 +141,8 @@ func TestTranslations(t *testing.T) { |
|
|
|
UniqueSlice []string `validate:"unique"` |
|
|
|
UniqueSlice []string `validate:"unique"` |
|
|
|
UniqueArray [3]string `validate:"unique"` |
|
|
|
UniqueArray [3]string `validate:"unique"` |
|
|
|
UniqueMap map[string]string `validate:"unique"` |
|
|
|
UniqueMap map[string]string `validate:"unique"` |
|
|
|
|
|
|
|
LowercaseString string `validate:"lowercase"` |
|
|
|
|
|
|
|
UppercaseString string `validate:"uppercase"` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var test Test |
|
|
|
var test Test |
|
|
@ -183,6 +185,9 @@ func TestTranslations(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
test.MultiByte = "1234feerf" |
|
|
|
test.MultiByte = "1234feerf" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test.LowercaseString = "ABCDEFG" |
|
|
|
|
|
|
|
test.UppercaseString = "abcdefg" |
|
|
|
|
|
|
|
|
|
|
|
s := "toolong" |
|
|
|
s := "toolong" |
|
|
|
test.StrPtrMaxLen = &s |
|
|
|
test.StrPtrMaxLen = &s |
|
|
|
test.StrPtrLen = &s |
|
|
|
test.StrPtrLen = &s |
|
|
@ -632,6 +637,14 @@ func TestTranslations(t *testing.T) { |
|
|
|
ns: "Test.UniqueMap", |
|
|
|
ns: "Test.UniqueMap", |
|
|
|
expected: "UniqueMap must contain unique values", |
|
|
|
expected: "UniqueMap must contain unique values", |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.LowercaseString", |
|
|
|
|
|
|
|
expected: "LowercaseString must be a lowercase string", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.UppercaseString", |
|
|
|
|
|
|
|
expected: "UppercaseString must be an uppercase string", |
|
|
|
|
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for _, tt := range tests { |
|
|
|
for _, tt := range tests { |
|
|
|