diff --git a/baked_in.go b/baked_in.go index caae8a7..0c05daa 100644 --- a/baked_in.go +++ b/baked_in.go @@ -2123,11 +2123,8 @@ func isDatetime(fl FieldLevel) bool { if field.Kind() == reflect.String { _, err := time.Parse(param, field.String()) - if err != nil { - return false - } - return true + return err == nil } panic(fmt.Sprintf("Bad field type %T", field.Interface())) diff --git a/validator_test.go b/validator_test.go index fe21574..d434e99 100644 --- a/validator_test.go +++ b/validator_test.go @@ -9375,7 +9375,7 @@ func TestUniqueValidationStructSlice(t *testing.T) { } } } - PanicMatches(t, func() { validate.Var(testStructs, "unique=C") }, "Bad field name C") + PanicMatches(t, func() { _ = validate.Var(testStructs, "unique=C") }, "Bad field name C") } func TestHTMLValidation(t *testing.T) { @@ -10143,7 +10143,7 @@ func TestGetTag(t *testing.T) { } val := New() - val.RegisterValidation("mytag", func(fl FieldLevel) bool { + _ = val.RegisterValidation("mytag", func(fl FieldLevel) bool { tag = fl.GetTag() return true })