Adds Collect — the all-errors-at-once counterpart to All:
v:=Collect(MinLength(8),Chars("a-z0-9"),NotIn("password"))err:=v(input)// every failure, not just the first
All is unchanged — same signature, still stops at the first failure. Collect is a separate function so nothing about All moves (this was the fast bool idea; it would have broken All's signature and every call site, including zampler/internal/database/files.go).
Collect runs every validator and returns the failures joined with errors.Join. errors.Is still matches each contained error, so errors.Is(err, ErrDisallowedChars) works whether one rule failed or five did. Zero failures → nil.
No new dependencies (errors.Join is stdlib, Go 1.20+).
New files only: collect.go, collect_test.go (table subtests + a runnable ExampleCollect). go vet + go test ./... green.
Closes #5.
Adds `Collect` — the all-errors-at-once counterpart to `All`:
```go
v := Collect(MinLength(8), Chars("a-z0-9"), NotIn("password"))
err := v(input) // every failure, not just the first
```
- `All` is **unchanged** — same signature, still stops at the first failure. `Collect` is a separate function so nothing about `All` moves (this was the `fast bool` idea; it would have broken `All`'s signature and every call site, including `zampler/internal/database/files.go`).
- `Collect` runs every validator and returns the failures joined with `errors.Join`. `errors.Is` still matches each contained error, so `errors.Is(err, ErrDisallowedChars)` works whether one rule failed or five did. Zero failures → `nil`.
- No new dependencies (`errors.Join` is stdlib, Go 1.20+).
New files only: `collect.go`, `collect_test.go` (table subtests + a runnable `ExampleCollect`). `go vet` + `go test ./...` green.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
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>
aneurin
merged commit e65d7d66c1 into main2026-09-07 12:50:51 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #5.
Adds
Collect— the all-errors-at-once counterpart toAll:Allis unchanged — same signature, still stops at the first failure.Collectis a separate function so nothing aboutAllmoves (this was thefast boolidea; it would have brokenAll's signature and every call site, includingzampler/internal/database/files.go).Collectruns every validator and returns the failures joined witherrors.Join.errors.Isstill matches each contained error, soerrors.Is(err, ErrDisallowedChars)works whether one rule failed or five did. Zero failures →nil.errors.Joinis stdlib, Go 1.20+).New files only:
collect.go,collect_test.go(table subtests + a runnableExampleCollect).go vet+go test ./...green.🤖 Generated with Claude Code