Skip to content

v0.25.0 - Enhanced Email Validation

Latest

Choose a tag to compare

@Zheruel Zheruel released this 07 Nov 21:38
7e6bfbd

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] and d'[email protected] now validate correctly
  • International Characters (Opt-in): Added allowInternational option for Unicode email support (e.g., josé@example.com, [email protected])
  • Full Branded Type Integration: Updated isValidEmail(), toEmail(), and assertEmail() 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.

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