Skip to content

[6/11] Add gt/lt strict numeric comparison checkers - #229

Merged
cinar merged 1 commit into
mainfrom
p1-06-gt-lt
Sep 5, 2026
Merged

[6/11] Add gt/lt strict numeric comparison checkers#229
cinar merged 1 commit into
mainfrom
p1-06-gt-lt

Conversation

@cinar

@cinar cinar commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Problem

gte/lte cover inclusive numeric bounds, but there's no strict-inequality equivalent — a common gap for users coming from validators that offer both.

Fix

Add gt/lt, mirroring gte.go/lte.go exactly, including the CanInt/CanUint/CanFloat handling from #193 and the non-numeric-field-panics contract:

  • gt.go/lt.go registered in maker.go under "gt"/"lt".
  • Added ExclusiveMinimum/ExclusiveMaximum to the Schema struct (nothing existing covered them) and mapped gt/lt to them in schema_maker.go, matching JSON Schema's exclusiveMinimum/exclusiveMaximum keywords.
  • NOT_GT/NOT_LT messages added to all 23 locale files plus en-US.

Bonus find, not fixed here: while writing these messages I noticed NOT_LTE's text is byte-identical to NOT_GTE's across every single locale file — a pre-existing copy-paste bug (lte's error currently says "cannot be less than X" when it should say "cannot be greater than X"). Left untouched since it's unrelated to this PR's scope; worth a small dedicated fix as a follow-up. Wrote correct, non-copy-pasted text for the new NOT_GT/NOT_LT messages so this PR doesn't propagate the same mistake.

Testing

  • gt_test.go/lt_test.go: value/boundary/error cases including an explicit "equal to bound is an error" test (the actual difference from gte/lte), int/uint/float, non-string... non-numeric-field panic, bad-param panic.
  • TestJSONSchemaGtLtExclusiveBounds plus bad-param panic tests for the new schema makers.
  • Full suite passes, 100% coverage maintained.
  • go vet, gosec, revive clean.

Fixes #203


Chain note: PR 6 of 11.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FLdVmP5daHiknrTW4Geh2i

gte/lte cover inclusive bounds, but there was no strict-inequality
equivalent, a common gap for users coming from other validators.

- gt.go/lt.go mirror gte.go/lte.go exactly, including the CanInt/
  CanUint/CanFloat handling from #193 and the ErrNotNumeric-preserving
  contract on a non-numeric field.
- Registered in maker.go under "gt"/"lt".
- Added ExclusiveMinimum/ExclusiveMaximum to the Schema struct (no
  existing field covered them) and mapped gt/lt to them in
  schema_maker.go, matching JSON Schema's exclusiveMinimum/
  exclusiveMaximum keywords.
- NOT_GT/NOT_LT messages added to all 23 locale files plus en-US.
  Along the way, spotted that NOT_LTE's message is byte-identical to
  NOT_GTE's across every single locale file -- a pre-existing
  copy-paste bug (lte's error says "cannot be less than" when it
  should say "cannot be greater than"), unrelated to this change and
  left alone here; worth a small dedicated fix later.
- Documented in the README's checker table.

Fixes #203

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FLdVmP5daHiknrTW4Geh2i
@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3511512) to head (b89e3b1).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #229   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           54        56    +2     
  Lines          983      1051   +68     
=========================================
+ Hits           983      1051   +68     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cinar
cinar merged commit ecbee13 into main Sep 5, 2026
8 checks passed
@cinar
cinar deleted the p1-06-gt-lt branch September 5, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add gt/lt strict numeric comparison checkers

1 participant