feature request: properly RFC-compliant email address parser
Premise
Emails cannot be properly parsed with regex. The docs say as much. However, zod has decided to parse emails in several semi-custom ways that boil down to "common sense"[1], the HTML5-equivalent regex according to MDN[2], or are an approximation of RFC5322[3].
Reasoning
Being fully RFC5322-compliant should at least be an option. A proper non-regex parser would also enable more fine-grained error messages and allow/disallow certain things like lack of a TLD or blacklist/whitelist certain email servers in a .refine() call.
Proposed Methodology
creating a new non-regex string parser that parses an email and returns a custom object with the parsed values inside in refine()
e.g.:
z.strictEmail({ allowUnicode: false }).refine(email => email.domain.at(-1) in ['com', 'org', 'de', 'at'])I don't know the zod internals well enough to know whether refine parameters can be different from response values, but having it as a codec producing a custom Email object instead would still be very useful.
Source: colinhacks/zod