Commit Graph
36 Commits
Author SHA1 Message Date
claudeandClaude Sonnet 5 4483105a78 docs: positioning README, package doc, usage examples
CI / test (pull_request) Successful in 43s
Closes #3.

- doc.go: package overview -- what a validator is, All vs Collect, errors
  are sentinels, how this compares to validator/v10 (tags+reflection),
  ozzo-validation (Rule interface) and govalidator (IsX helpers), and when
  to pick something else.
- README.md: rewritten from three lines to a positioning intro, a
  "why this and not X" table, a building-blocks table, and a
  "not a fit if" note.
- example_test.go: runnable Example (compose built-ins + a closure),
  Example_collectAll (errors.Is over a joined error), Example_errorsIs
  (sentinel matching, Err as match-anything).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-07 14:01:03 +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
claudeandClaude Sonnet 5 7ea26f9c88 add CI workflow running go vet and go test
CI / test (push) Successful in 1m20s
Adds .gitea/workflows/ci.yml: on push to main and on pull requests, run
`go vet ./...` then `go test ./...` in a golang:1.21-alpine container.

Also removes .github/workflows/test.yml, which only triggered on a
`develop` branch that no longer exists and depended on an external
Discord notification action and an unset DISCORD_WEBHOOK secret.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-07 12:53:18 +00:00
aneurinandClaude Sonnet 5 a992065d6c email: validate with net/mail.ParseAddress
Replace the RFC 5322 mega-regexp with net/mail.ParseAddress, which is the
standard library's address parser and far easier to audit. A bare address
is required: inputs with a display name, angle brackets, a comment, or
trailing content are rejected, as is an address list.

Behaviour change: ParseAddress does not require the domain to contain a
dot, so "alice@localhost" now validates. Layer Match or a DNS lookup on
top if a stricter domain is needed.

Also rewrites FuzzEmail, which previously asserted that *every* input is
invalid, into checks that Email never returns an unexpected error type,
never panics, and gives a stable verdict.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-07 12:53:02 +00:00
aneurinandClaude Sonnet 5 82611a5e96 add Required, Prefix, Suffix, Contains, Match validators
Broadens the built-in set with the string/presence checks that came up
most often when reaching for this package:

  - Required[T comparable]  non-zero value
  - Prefix / Suffix / Contains  strings.HasPrefix/HasSuffix/Contains
  - Match(*regexp.Regexp)  arbitrary pattern

All follow the existing shape: a constructor returning func(T) error, a
sentinel error matched with errors.Is, table-driven tests and an Example.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-07 12:51:42 +00:00
claudeandClaude Sonnet 5 e65d7d66c1 add Collect: run every validator and join all errors
Collect is the all-errors-at-once counterpart to All. All still stops at
the first failure (unchanged); Collect runs every function and returns the
failures joined with errors.Join, which errors.Is still matches element by
element. Kept as a separate function rather than a flag on All so All's
signature and behaviour don't change.

Closes #5

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-07 13:47:38 +01:00
aneurin 8fab67ff77 update package name 2026-07-05 23:38:45 +01:00
Aneurin Barker Snook dff0caf40b fix link to license 2024-07-19 14:29:46 +01:00
Aneurin Barker Snook b8c82f3529 remove unnecessary doc comments 2024-07-19 14:11:53 +01:00
Aneurin Barker Snook 45298c462a ensure go.sum not committed 2024-07-19 14:11:34 +01:00
Aneurin Barker Snook 38b1cf53d8 remove unnecessary staticcheck.conf 2024-07-18 08:36:08 +01:00
Aneurin Barker Snook c1d7c423a7 simplify readme 2024-07-18 08:24:36 +01:00
Aneurin Barker Snook 5b0e0ca1ec restore staticcheck, test ci 2024-07-18 08:24:36 +01:00
Aneurin Barker Snook 15b4c91cf0 rename package 2024-07-18 08:24:36 +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 4c99b5a654 duplicate license to each package 2024-07-11 17:33:18 +01:00
Aneurin Barker Snook ad75934954 add readme for each package 2024-06-21 21:54:44 +01:00
Aneurin Barker Snook d55961c207 migrate from recipeer org to annybs 2024-04-25 22:00:39 +01:00
Aneurin Barker Snook a31f5d500a add url validator 2023-11-26 12:00:15 +00:00
Aneurin Barker Snook 7160519ec3 fix go version to 1.21 2023-11-20 21:02:21 +00:00
Aneurin Barker Snook 034557c12d add ExceptChars validator 2023-11-20 17:59:05 +00:00
Aneurin Barker Snook 40482060ac update all validation tests 2023-11-19 20:42:48 +00:00
Aneurin Barker Snook db902e3c1c add validation error type, fix tests, add number tests 2023-11-19 20:27:33 +00:00
Aneurin Barker Snook 196e1faeeb add basic number validation 2023-11-19 19:33:34 +00:00
Aneurin Barker Snook d59fb7b944 fix size validation error again, add tests 2023-10-16 17:43:05 +01:00
Aneurin Barker Snook 7701f5c6fa fix size errors wrong way around 2023-10-14 14:00:22 +01:00
Aneurin Barker Snook f929f4ffff add slice size validation 2023-10-13 21:16:13 +01:00
Aneurin Barker Snook 9537961e29 add validate.Equal 2023-10-12 19:55:08 +01:00
Aneurin Barker Snook 1cb434327a number tests 2023-10-08 16:20:21 +01:00
Aneurin Barker Snook 7cb1900ec1 standardise all validate tests 2023-10-08 15:21:02 +01:00
Aneurin Barker Snook c74486d122 add all validator, simplify error messages 2023-10-07 13:42:17 +01:00
Aneurin Barker Snook c2efe16dc0 add generic in/not in validation 2023-10-07 11:24:34 +01:00
Aneurin Barker Snook b4b5b8b752 add chars validation 2023-10-07 10:52:11 +01:00
Aneurin Barker Snook 1a3c213dc1 make tests slightly easier to write 2023-10-07 10:44:47 +01:00
Aneurin Barker Snook 923734fe25 add min/max length validation, improve tests 2023-10-07 10:43:21 +01:00
Aneurin Barker Snook f41d6f248a add workspace, validation 2023-10-06 11:58:24 +01:00