diff --git a/baked_in.go b/baked_in.go index a589ecc..338cddd 100644 --- a/baked_in.go +++ b/baked_in.go @@ -1308,7 +1308,11 @@ func hasValue(fl FieldLevel) bool { func requireCheckFieldKind(fl FieldLevel, param string) bool { field := fl.Field() if len(param) > 0 { - field = fl.Parent().FieldByName(param) + if fl.Parent().Kind() == reflect.Ptr { + field = fl.Parent().Elem().FieldByName(param) + } else { + field = fl.Parent().FieldByName(param) + } } switch field.Kind() { case reflect.Slice, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func: diff --git a/validator_test.go b/validator_test.go index 1e5d37f..a8ccfaa 100644 --- a/validator_test.go +++ b/validator_test.go @@ -8712,7 +8712,7 @@ func TestRequiredWithout(t *testing.T) { Field5: "test", } - errs = validate.Struct(test2) + errs = validate.Struct(&test2) if errs == nil { t.Fatalf("failed Error: %s", errs)