|
|
|
@ -27,6 +27,7 @@ func TestTranslations(t *testing.T) { |
|
|
|
|
GteCSFieldString string |
|
|
|
|
LtCSFieldString string |
|
|
|
|
LteCSFieldString string |
|
|
|
|
RequiredIf string |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type Test struct { |
|
|
|
@ -34,6 +35,7 @@ func TestTranslations(t *testing.T) { |
|
|
|
|
RequiredString string `validate:"required"` |
|
|
|
|
RequiredNumber int `validate:"required"` |
|
|
|
|
RequiredMultiple []string `validate:"required"` |
|
|
|
|
RequiredIf string `validate:"required_if=Inner.RequiredIf abcd"` |
|
|
|
|
LenString string `validate:"len=1"` |
|
|
|
|
LenNumber float64 `validate:"len=1113.00"` |
|
|
|
|
LenMultiple []string `validate:"len=7"` |
|
|
|
@ -202,6 +204,8 @@ func TestTranslations(t *testing.T) { |
|
|
|
|
test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"} |
|
|
|
|
test.Datetime = "2008-Feb-01" |
|
|
|
|
|
|
|
|
|
test.Inner.RequiredIf = "abcd" |
|
|
|
|
|
|
|
|
|
err = validate.Struct(test) |
|
|
|
|
NotEqual(t, err, nil) |
|
|
|
|
|
|
|
|
@ -592,6 +596,10 @@ func TestTranslations(t *testing.T) { |
|
|
|
|
ns: "Test.RequiredString", |
|
|
|
|
expected: "RequiredString is a required field", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
ns: "Test.RequiredIf", |
|
|
|
|
expected: "RequiredIf is a required field", |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
ns: "Test.RequiredNumber", |
|
|
|
|
expected: "RequiredNumber is a required field", |
|
|
|
|