Enhanced Email Validation with Apostrophe and International Character Support
This release significantly improves email validation to handle real-world email addresses more accurately.
✨ Key Features
- Apostrophe Support (Default): Emails like
o'[email protected]andd'[email protected]now validate correctly - International Characters (Opt-in): Added
allowInternationaloption for Unicode email support (e.g.,josé@example.com,mü[email protected]) - Full Branded Type Integration: Updated
isValidEmail(),toEmail(), andassertEmail()with options support - TypeScript Overload Signatures: Better IDE autocomplete for
assertEmail()
⚠️ Breaking Changes
Apostrophes (') are now allowed by default in email addresses. This makes the validator more permissive to handle real-world names like O'Connor, D'Angelo, etc.
- Before:
isEmail("o'[email protected]")→false - After:
isEmail("o'[email protected]")→true
International characters remain rejected by default (opt-in only via { allowInternational: true }).
🧪 Testing
- 13+ new comprehensive tests
- 1,484 total tests passing
- 100% test coverage maintained
- Code quality review: 8.5/10 rating
📦 Bundle Size
- Minimal impact: ~30 bytes added
- ESM: 9.14 KB (well under 12 KB limit)
📖 Usage Examples
```typescript
// Apostrophes work by default
isEmail("o'[email protected]") // true
// International characters require opt-in
isEmail("josé@example.com") // false
isEmail("josé@example.com", { allowInternational: true }) // true
// Branded types support options
const email = toEmail("mü[email protected]", { allowInternational: true })
assertEmail("user@café.com", { allowInternational: true })
```
Fixes: #57
Full Changelog: https://github.com/Zheruel/nano-string-utils/blob/main/CHANGELOG.md