Boolean translation (#930)

*  add en boolean translation
*  add pt-BR boolean translation
pull/936/head
Eduardo Mello 3 years ago committed by GitHub
parent d37da5e53c
commit e3f29bf088
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      translations/en/en.go
  2. 6
      translations/en/en_test.go
  3. 5
      translations/pt_BR/pt_BR.go
  4. 6
      translations/pt_BR/pt_BR_test.go

@ -1351,6 +1351,11 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return t return t
}, },
}, },
{
tag: "boolean",
translation: "{0} must be a valid boolean value",
override: false,
},
} }
for _, t := range translations { for _, t := range translations {

@ -151,6 +151,7 @@ func TestTranslations(t *testing.T) {
PostCode string `validate:"postcode_iso3166_alpha2=SG"` PostCode string `validate:"postcode_iso3166_alpha2=SG"`
PostCodeCountry string PostCodeCountry string
PostCodeByField string `validate:"postcode_iso3166_alpha2_field=PostCodeCountry"` PostCodeByField string `validate:"postcode_iso3166_alpha2_field=PostCodeCountry"`
BooleanString string `validate:"boolean"`
} }
var test Test var test Test
@ -203,6 +204,7 @@ func TestTranslations(t *testing.T) {
test.UniqueSlice = []string{"1234", "1234"} test.UniqueSlice = []string{"1234", "1234"}
test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"} test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"}
test.Datetime = "2008-Feb-01" test.Datetime = "2008-Feb-01"
test.BooleanString = "A"
test.Inner.RequiredIf = "abcd" test.Inner.RequiredIf = "abcd"
@ -684,6 +686,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.PostCodeByField", ns: "Test.PostCodeByField",
expected: "PostCodeByField does not match postcode format of country in PostCodeCountry field", expected: "PostCodeByField does not match postcode format of country in PostCodeCountry field",
}, },
{
ns: "Test.BooleanString",
expected: "BooleanString must be a valid boolean value",
},
} }
for _, tt := range tests { for _, tt := range tests {

@ -1316,6 +1316,11 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
return s return s
}, },
}, },
{
tag: "boolean",
translation: "{0} deve ser um valor booleano válido",
override: false,
},
} }
for _, t := range translations { for _, t := range translations {

@ -139,6 +139,7 @@ func TestTranslations(t *testing.T) {
StrPtrGte *string `validate:"gte=10"` StrPtrGte *string `validate:"gte=10"`
OneOfString string `validate:"oneof=red green"` OneOfString string `validate:"oneof=red green"`
OneOfInt int `validate:"oneof=5 63"` OneOfInt int `validate:"oneof=5 63"`
BooleanString string `validate:"boolean"`
} }
var test Test var test Test
@ -171,6 +172,7 @@ func TestTranslations(t *testing.T) {
test.AlphanumString = "abc3!" test.AlphanumString = "abc3!"
test.NumericString = "12E.00" test.NumericString = "12E.00"
test.NumberString = "12E" test.NumberString = "12E"
test.BooleanString = "A"
test.Excludes = "este é um texto de teste" test.Excludes = "este é um texto de teste"
test.ExcludesAll = "Isso é Ótimo!" test.ExcludesAll = "Isso é Ótimo!"
@ -619,6 +621,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.OneOfInt", ns: "Test.OneOfInt",
expected: "OneOfInt deve ser um de [5 63]", expected: "OneOfInt deve ser um de [5 63]",
}, },
{
ns: "Test.BooleanString",
expected: "BooleanString deve ser um valor booleano válido",
},
} }
for _, tt := range tests { for _, tt := range tests {

Loading…
Cancel
Save