Skip to content

Latest commit

 

History

History
77 lines (53 loc) · 2.46 KB

README.md

File metadata and controls

77 lines (53 loc) · 2.46 KB

email_typo

Tests Code Climate Gem Gem

EmailTypo is a Ruby gem that gives you an easy, tested method that fixes email typos.

As an example: A user with the email "[email protected]" accidentally enters in "[email protected]", EmailTypo will fix it automatically.

EmailTypo is concerned with incorrectly-entered data (email provider names, TLDs), not with evaluating whether a particular domain is valid, or whether a particular email address is legitimate. (That is, it's focused on fixing the part that comes after the "@" in the email address.) It works really well for helping you — and your users — when they accidentally type something in wrong.

NOTE: This is based on https://github.com/charliepark/fat_fingers, but without polluting the String class and with easier extension support.

Installation

gem install email_typo

Or add the following line to your project's Gemfile:

gem "email_typo"

Usage

To fix any typos, just use EmailTypo.call(email).

EmailTypo.call("[email protected]")
#=> "[email protected]"

To add/change the processors, add any object that responds to #call(email) to EmailTypo.default_processors. The following example adds a processor for .uol.com.br, a Brazilian email provider:

EmailTypo.default_processors << lambda do |email|
  email.gsub(/@uol\.com(\..*?)?/, "@uol.com.br")
end

Maintainer

Contributors

Contributing

For more details about how to contribute, please read https://github.com/fnando/email_typo/blob/main/CONTRIBUTING.md.

License

The gem is available as open source under the terms of the MIT License. A copy of the license can be found at https://github.com/fnando/email_typo/blob/main/LICENSE.md.

Code of Conduct

Everyone interacting in the email_typo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.