Commit Graph
8 Commits
Author SHA1 Message Date
claudeandClaude Sonnet 5 164dcbf367 length: add MinLengthBytes / MaxLengthBytes
CI / test (pull_request) Successful in 34s
CI / test (push) Successful in 37s
MinLength/MaxLength now count runes, leaving no way to bound a string by
its byte size -- still wanted for fixed-width columns and wire-format
fields. Add the byte-counting pair alongside them, with their own "%d
bytes" sentinels (ErrMustHaveMoreBytes / ErrMustHaveFewerBytes).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-07 16:48:29 +01:00
claudeandClaude Sonnet 5 4e2e05c1b9 length: count runes, not bytes
CI / test (pull_request) Successful in 34s
MinLength/MaxLength measured len(value), so a string of 8 accented
characters (9+ bytes) failed MaxLength(8) despite the error message
promising "characters". Count with utf8.RuneCountInString so the check
matches the wording and the common-sense intent.

Still not grapheme-cluster aware (combining marks, emoji ZWJ sequences
count as several runes), which is out of scope for a stdlib-only helper.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-07 16:27:22 +01:00
claudeandClaude Sonnet 5 da971f4df5 fix incorrect and vague doc comments
Audit ahead of the README/doc.go work (issue #3):

- number.go: Min, MinFloat32, MinFloat64 all said "less than or equal to a
  given maximum" -- copy-pasted from the Max family. They check the
  minimum. Fixed.
- chars_test.go: ExampleExceptChars called Chars, not ExceptChars, so it
  never exercised the function it documents.
- chars.go: "does not contain disallowed characters" was circular.
- in.go: NotIn's parameter was named "allow"; renamed to "disallow".
- length.go: note that length is bytes (len), not runes -- the "%d
  characters" messages imply otherwise.
- url.go: spell out that ParseRequestURI wants an absolute URL or path.
- uuid.go: note lowercase-hex only, version/variant not checked.
- error.go: explain Err (the match-anything sentinel), how Error() formats
  with Data, and what With does. all.go: point at Collect.

Comments only; no behaviour change. go vet + go test ./... pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-07 13:59:59 +01:00
Aneurin Barker Snook b8c82f3529 remove unnecessary doc comments 2024-07-19 14:11:53 +01:00
Aneurin Barker Snook a9c1184d6b improve validate testing with examples
also simplified structure of test cases and failure logging
2024-07-18 06:53:20 +01:00
Aneurin Barker Snook 40482060ac update all validation tests 2023-11-19 20:42:48 +00:00
Aneurin Barker Snook c74486d122 add all validator, simplify error messages 2023-10-07 13:42:17 +01:00
Aneurin Barker Snook 923734fe25 add min/max length validation, improve tests 2023-10-07 10:43:21 +01:00