diff options
author | Horatiu Eugen Vlad <horatiu@vlad.eu> | 2018-10-27 01:39:00 +0300 |
---|---|---|
committer | Horatiu Eugen Vlad <horatiu@vlad.eu> | 2019-03-05 22:56:01 +0300 |
commit | c8c0ea6c52d46ce63d838d1e739355d4deace434 (patch) | |
tree | a91cbe57b1cc4235f3be6b32f2829e200c73de09 /app/models | |
parent | 60876192f89e41494cb56e2dc0a90f5f0dbfa716 (diff) |
Align EmailValidator to validate_email gem implementation.
Renamed EmailValidator to DeviseEmailValidator to avoid 'email:' naming collision with ActiveModel::Validations::EmailValidator in 'validates' statement.
Make use of the options attribute of the parent class ActiveModel::EachValidator.
Add more options: regex.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/application_setting.rb | 2 | ||||
-rw-r--r-- | app/models/email.rb | 2 | ||||
-rw-r--r-- | app/models/member.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 6 |
4 files changed, 6 insertions, 6 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 88746375c67..f83f9691194 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -69,7 +69,7 @@ class ApplicationSetting < ActiveRecord::Base url: true validates :admin_notification_email, - email: true, + devise_email: true, allow_blank: true validates :two_factor_grace_period, diff --git a/app/models/email.rb b/app/models/email.rb index 3ce6e792fa8..7c33c5c7e64 100644 --- a/app/models/email.rb +++ b/app/models/email.rb @@ -7,7 +7,7 @@ class Email < ActiveRecord::Base belongs_to :user validates :user_id, presence: true - validates :email, presence: true, uniqueness: true, email: true + validates :email, presence: true, uniqueness: true, devise_email: true validate :unique_email, if: ->(email) { email.email_changed? } scope :confirmed, -> { where.not(confirmed_at: nil) } diff --git a/app/models/member.rb b/app/models/member.rb index 8e071a8ff21..5dbc0c2eec9 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -28,7 +28,7 @@ class Member < ActiveRecord::Base presence: { if: :invite? }, - email: { + devise_email: { allow_nil: true }, uniqueness: { diff --git a/app/models/user.rb b/app/models/user.rb index 9c091ac366c..14cedd9c4d1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -162,9 +162,9 @@ class User < ApplicationRecord validates :name, presence: true validates :email, confirmation: true validates :notification_email, presence: true - validates :notification_email, email: true, if: ->(user) { user.notification_email != user.email } - validates :public_email, presence: true, uniqueness: true, email: true, allow_blank: true - validates :commit_email, email: true, allow_nil: true, if: ->(user) { user.commit_email != user.email } + validates :notification_email, devise_email: true, if: ->(user) { user.notification_email != user.email } + validates :public_email, presence: true, uniqueness: true, devise_email: true, allow_blank: true + validates :commit_email, devise_email: true, allow_nil: true, if: ->(user) { user.commit_email != user.email } validates :bio, length: { maximum: 255 }, allow_blank: true validates :projects_limit, presence: true, |