pull/979/head
Thanakrit Nawasaykaew 2 years ago
parent 3714556d17
commit 0a5beb78fa
  1. 24
      validator_test.go

@ -12285,4 +12285,26 @@ func TestMultiOrOperatorGroup(t *testing.T) {
} }
} }
} }
} }
type testTag struct {
CreatedAt *time.Time `validate:"required" langKey:"test.created_at"`
String string `validate:"required" langKey:"test.string"`
Int int `validate:"required" langKey:"test.int"`
Uint uint `validate:"required" langKey:"test.uint"`
Float float64 `validate:"required" langKey:"test.float"`
Array []string `validate:"required" langKey:"test.array"`
}
func TestReflectStructField(t *testing.T) {
validate := New()
var test testTag
err := validate.Struct(test)
NotEqual(t, err, nil)
errs, ok := err.(ValidationErrors)
Equal(t, ok, true)
fe := errs[0]
Equal(t, fe.ReflectStructField().Tag.Get("langKey"), "test.created_at")
}

Loading…
Cancel
Save