• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gookit / validate / 26208967737

21 May 2026 06:14AM UTC coverage: 95.604% (-0.1%) from 95.701%
26208967737

Pull #335

github

SAY-5
fix(validators): handle pointer fields in RequiredIf

RequiredIf silently skipped its check whenever either side of the rule
was a pointer:

  - When the destination field is a pointer (e.g. *bool), reflect.ValueOf
    returns a value of Kind Pointer. convTypeByBaseKind has no
    string-to-Pointer conversion, so dstVal == wantVal was never
    evaluated and the function fell through to default-True / skip.

  - When the source field is a pointer to a zero value (e.g.
    *string("")), val != nil && !IsEmpty(val) was true, so the
    rule's 'must be present and not empty' contract was not enforced.

Unwrap pointers on both sides: treat a nil pointer as the field being
absent (rule does not trigger, dependent field remains optional), and
treat a pointer to a zero value as the zero value itself for the
not-empty check. Adds five subtests covering each pointer scenario;
two of them fail on the old code and pass on the new code.

Closes #334
Pull Request #335: fix(validators): handle pointer fields in RequiredIf (#334)

22 of 26 new or added lines in 1 file covered. (84.62%)

3001 of 3139 relevant lines covered (95.6%)

7.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.38
/validators.go


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc