Conversation
min-len/max-len exist but there was no single-tag way to require an exact length -- phone numbers, fixed-width codes, postal codes. - len.go mirrors min_len.go exactly, including the generic Len[T any] signature usable standalone with any Len()-able type, and the same v.Len() (byte length, not rune count) semantics already used by min-len/max-len -- kept consistent with its siblings rather than introducing a rune-counting discrepancy between the three. - Registered in maker.go. - Mapped in schema_maker.go to matching Min/Max pairs (MinLength= MaxLength, MinItems=MaxItems, or MinProperties=MaxProperties, depending on kind), since an exact length is just min=max. - NOT_LEN message added to all 23 locale files plus en-US. - Documented in the README's checker table. Fixes #207 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FLdVmP5daHiknrTW4Geh2i
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #236 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 63 64 +1
Lines 1163 1196 +33
=========================================
+ Hits 1163 1196 +33 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces #233, which GitHub auto-closed (rather than retargeted) when its base branch (
p1-09-contains-family) was deleted after #232 merged. Same content, rebased onto currentmain.Problem
min-len/max-lenexist but there was no single-tag way to require an exact length — phone numbers, fixed-width codes, postal codes.Fix
Add
len, mirroringmin_len.goexactly:Len[T any]signature is usable standalone with anyLen()-able type, and uses the samev.Len()(byte length, not rune count) semantics already used bymin-len/max-len— kept consistent with its siblings rather than introducing a rune-counting discrepancy between the three.maker.go.schema_maker.goto matching Min/Max pairs (MinLength=MaxLength,MinItems=MaxItems, orMinProperties=MaxProperties, depending on kind), since an exact length is just min=max.NOT_LENmessage added to all 23 locale files plus en-US.Testing
len_test.go: standalone generic usage, string/slice struct-tag valid/invalid, bad-param panic, non-Len()-able-type panic.TestJSONSchemaLenExactLengthcovering string/slice/map, plus a bad-param panic test.go vet,gosec,reviveclean.Fixes #207
🤖 Generated with Claude Code
https://claude.ai/code/session_01FLdVmP5daHiknrTW4Geh2i