clearance
clearance copied to clipboard
Refactor Clearance::User::Validations to use a more thorough email format validation regex
Currently, the Clearance::User::Validations module uses the following for email format validation:
validates_format_of :email, :with => %r{.+@.+\..+}, :allow_blank => true
Unfortunately, this is not a very thorough email format validation regex and allows emails addresses such as [email protected] and [email protected] to pass validation. I would like to see the email format validation regex suggested by http://www.regular-expressions.info/email.html used instead (Includes the addition of ^ and $ as well as the case-insensitive flag at the end) :
validates_format_of :email, :with => %r{^[a-z0-9!#\$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#\$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$}i, :allow_blank => true
The commit/code for this change can be found here: https://github.com/RobertStevenson/clearance/commit/2ce9c63853be8ca5fda2f710a57f3d0f181a6313
Merged into master. Thanks!