mailfix 0.37.1 copy "mailfix: ^0.37.1" to clipboard
mailfix: ^0.37.1 copied to clipboard

Package for email validation with domain correction suggestions using configurable similarity algorithms.

Mailfix Logo

Mailfix #

A powerful Dart/Flutter package for email validation and correction suggestions using advanced string similarity algorithms.


Features #

Installation #

dependencies:
  mailfix: ^0.0.5

Mailfix Demo

Usage #

Simple Example #

import 'package:mailfix/mailfix.dart';

void main() {
  final mailfix = Mailfix();
  final result = mailfix.validateEmail('user@gmal.com');
  print(result.suggestion); // Suggests: user@gmail.com
}

Basic Usage #

import 'package:mailfix/mailfix.dart';

void main() {
  final mailfix = Mailfix();
  
  final result = mailfix.validateEmail('user@gmal.com');
  if (!result.isValid) {
    if (result.suggestion != null) {
      print('Suggestion: \\${result.suggestion}'); // Will suggest gmail.com
    } else {
      print('Error: \\${result.error}');
    }
  }
}

Custom Configuration #

final mailfix = Mailfix(
  // Choose similarity algorithm
  algorithm: MailfixSimilarityAlgorithm.damerauLevenshtein,
  // Configure similarity threshold
  maxAllowedDistance: 3,
);

// Add custom domains
mailfix.addDomain('company.com');
mailfix.addDomains(['domain1.com', 'domain2.com']);

Custom Validator #

class MyEmailValidator implements EmailValidatorInterface {
  @override
  bool isValid(String email) {
    // Your custom validation logic
    return true;
  }
}

Live Example #

Test the Mailfix library right now:

  1. Visit our interactive demo
  2. Type an email with typos (e.g., "user@gmial.com")
  3. See the correction suggestions in real time

The complete example code is available in the repository for you to implement in your project.

Algorithms #

Jaro-Winkler Similarity (Default) #

Optimized for short strings and gives more favorable ratings to strings that match from the beginning. Good for catching subtle differences in domain names. Read more

Levenshtein Distance #

Best for general purpose use. Calculates the minimum number of single-character edits required to change one string into another. Read more

Damerau-Levenshtein Distance #

Better for catching transposition errors (when two adjacent characters are swapped). Particularly useful for email domains where typos often involve character swaps. Read more

Contributing #

Contributions are welcome! Please feel free to submit a Pull Request.

1
likes
160
points
365
downloads
screenshot

Publisher

verified publishervaldir.dev.br

Weekly Downloads

Package for email validation with domain correction suggestions using configurable similarity algorithms.

Repository (GitHub)
View/report issues

Topics

#email #validation #domain-correction #levenshtein #jaro-winkler

Documentation

API reference

License

MIT (license)

Dependencies

email_validator

More

Packages that depend on mailfix