pull/1099/merge
iBet7o 1 year ago committed by GitHub
commit 9e36af495d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      translations/es/es.go
  2. 18
      translations/es/es_test.go

@ -34,6 +34,21 @@ func RegisterDefaultTranslations(v *validator.Validate, trans ut.Translator) (er
translation: "{0} es un campo requerido",
override: false,
},
{
tag: "required_without",
translation: "{0} es un campo requerido cuando los campos [{1}] no estan presentes",
customTransFunc: func(ut ut.Translator, fe validator.FieldError) string {
t, err := ut.T(fe.Tag(), fe.Field(), fe.Param())
if err != nil {
fmt.Printf("warning: error translating FieldError: %#v", fe)
return fe.(error).Error()
}
return t
},
override: false,
},
{
tag: "len",
customRegisFunc: func(ut ut.Translator) (err error) {

@ -22,12 +22,13 @@ func TestTranslations(t *testing.T) {
Equal(t, err, nil)
type Inner struct {
EqCSFieldString string
NeCSFieldString string
GtCSFieldString string
GteCSFieldString string
LtCSFieldString string
LteCSFieldString string
EqCSFieldString string
NeCSFieldString string
GtCSFieldString string
GteCSFieldString string
LtCSFieldString string
LteCSFieldString string
RequiredWithoutField string
}
type Test struct {
@ -36,6 +37,7 @@ func TestTranslations(t *testing.T) {
RequiredNumber int `validate:"required"`
RequiredMultiple []string `validate:"required"`
RequiredIf string `validate:"required_if=Inner.RequiredIf abcd"`
RequiredWithout string `validate:"required_without=Inner.RequiredWithoutField"`
LenString string `validate:"len=1"`
LenNumber float64 `validate:"len=1113.00"`
LenMultiple []string `validate:"len=7"`
@ -638,6 +640,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.UniqueMap",
expected: "UniqueMap debe contener valores únicos",
},
{
ns: "Test.RequiredWithout",
expected: "RequiredWithout es un campo requerido cuando los campos [Inner.RequiredWithoutField] no estan presentes",
},
}
for _, tt := range tests {

Loading…
Cancel
Save