Commit Graph
3 Commits
Author SHA1 Message Date
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
aneurin 8fab67ff77 update package name 2026-07-05 23:38:45 +01:00