First, conservative expansion of the built-in set (see #6), all in the existing style — constructor returning func(T) error, sentinel error matched with errors.Is, table-driven tests plus an Example:
Validator
Checks
Required[T comparable]()
value is not the zero value
Prefix(p) / Suffix(s) / Contains(sub)
strings.HasPrefix / HasSuffix / Contains
Match(re *regexp.Regexp)
string matches the pattern
New files: required.go, string.go, match.go (+ tests). No dependencies added, no changes to existing files. go vet + go test ./... green.
Further candidates (Between, NotBlank, OneOf, IP/CIDR, time bounds, …) are listed in #6 for triage rather than dumped here.
First, conservative expansion of the built-in set (see #6), all in the existing style — constructor returning `func(T) error`, sentinel error matched with `errors.Is`, table-driven tests plus an `Example`:
| Validator | Checks |
|---|---|
| `Required[T comparable]()` | value is not the zero value |
| `Prefix(p)` / `Suffix(s)` / `Contains(sub)` | `strings.HasPrefix` / `HasSuffix` / `Contains` |
| `Match(re *regexp.Regexp)` | string matches the pattern |
New files: `required.go`, `string.go`, `match.go` (+ tests). No dependencies added, no changes to existing files. `go vet` + `go test ./...` green.
Further candidates (`Between`, `NotBlank`, `OneOf`, `IP`/`CIDR`, time bounds, …) are listed in #6 for triage rather than dumped here.
Closes #6
🤖 Generated with [Claude Code](https://claude.com/claude-code)
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>
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.
First, conservative expansion of the built-in set (see #6), all in the existing style — constructor returning
func(T) error, sentinel error matched witherrors.Is, table-driven tests plus anExample:Required[T comparable]()Prefix(p)/Suffix(s)/Contains(sub)strings.HasPrefix/HasSuffix/ContainsMatch(re *regexp.Regexp)New files:
required.go,string.go,match.go(+ tests). No dependencies added, no changes to existing files.go vet+go test ./...green.Further candidates (
Between,NotBlank,OneOf,IP/CIDR, time bounds, …) are listed in #6 for triage rather than dumped here.Closes #6
🤖 Generated with Claude Code