|
|
|
@ -138,6 +138,9 @@ func TestTranslations(t *testing.T) { |
|
|
|
|
StrPtrGte *string `validate:"gte=10"` |
|
|
|
|
OneOfString string `validate:"oneof=red green"` |
|
|
|
|
OneOfInt int `validate:"oneof=5 63"` |
|
|
|
|
UniqueSlice []string `validate:"unique"` |
|
|
|
|
UniqueArray [3]string `validate:"unique"` |
|
|
|
|
UniqueMap map[string]string `validate:"unique"` |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var test Test |
|
|
|
@ -184,6 +187,9 @@ func TestTranslations(t *testing.T) { |
|
|
|
|
test.StrPtrMaxLen = &s |
|
|
|
|
test.StrPtrLen = &s |
|
|
|
|
|
|
|
|
|
test.UniqueSlice = []string{"1234", "1234"} |
|
|
|
|
test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"} |
|
|
|
|
|
|
|
|
|
err = validate.Struct(test) |
|
|
|
|
NotEqual(t, err, nil) |
|
|
|
|
|
|
|
|
@ -614,6 +620,18 @@ func TestTranslations(t *testing.T) { |
|
|
|
|
ns: "Test.OneOfInt", |
|
|
|
|
expected: "OneOfInt must be one of [5 63]", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
ns: "Test.UniqueSlice", |
|
|
|
|
expected: "UniqueSlice must contain unique values", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
ns: "Test.UniqueArray", |
|
|
|
|
expected: "UniqueArray must contain unique values", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
ns: "Test.UniqueMap", |
|
|
|
|
expected: "UniqueMap must contain unique values", |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for _, tt := range tests { |
|
|
|
|