Use the same email validation for User and Email
All threads resolved!
All threads resolved!
Compare changes
Files
5- Magdalena Frankiewicz authored
Otherwise, it is possible that a `User` primary email is successfully saved, but it cannot be added to the emails table due to being invalid for the `Email` model. The `Email#email` validation is now more relaxed, and the same as the `User#email` validation: it is the Devise email validation, that basically only checks that there is a single @ sign separating local part and domain. The previous stricter Email#email validation was enforcing compliance with RFC3696, but many mail servers allow addresses that are not fully compliant with the RFC. Therefore, the relaxed validation is preferable, to avoid blocking working email addresses.
+ 2
− 6
@@ -6,8 +6,8 @@ class Email < ApplicationRecord
@@ -6,8 +6,8 @@ class Email < ApplicationRecord
@@ -33,10 +33,6 @@ def unique_email
@@ -33,10 +33,6 @@ def unique_email
self.errors.add(:email, I18n.t(:invalid, scope: 'valid_email.validations.email')) unless ValidateEmail.valid?(self.email)