Email validation with disposable detection, blocklists and allowlists in TypeScript
说明与用途
mailrules 让开发者配置邮箱验证规则,包括阻止临时邮箱、黑名单、白名单和域名限制,并返回稳定的拒绝原因代码。
问题
An email can have valid syntax and still fail an application's signup rules, such as rejecting disposable providers, blocking specific mailboxes, or accepting only addresses from a company's domain.
结果
mailrules enables developers to enforce complex email validation policies without network requests, providing clear reason codes for each rejection and supporting custom disposable domain data.
工作流
- Install mailrules via npm
- Create a validator with createEmailValidator and configure blocklist, allowlist, or disposableDomains
- Reuse the validator instance for multiple checks
- Call validator.check(email) to get a result object with valid and reasons
- Use allowlistMode:'only' to restrict access to specific domains or addresses
- Set includeSubdomains:false to require exact domain matches
- Update dependencies or supply new data to refresh disposable domain lists
证据
I built mailrules to bring those decisions into one configurable TypeScript/JavaScript API.
Create the validator once and reuse it. Lists are copied, normalized and indexed during construction. Validation is synchronous and makes no network requests.
An explicit block always wins over an allowlist exception. The result includes a stable reason code so the application can decide what feedback to show.
- 记录日期: 2026-10-27T01:11:17.374Z