Skip to content

Commit

Permalink
Merge pull request #3395 from JDutil/fixes-1794
Browse files Browse the repository at this point in the history
Remove Deprecated EmailValidator
  • Loading branch information
kennyadsl authored Nov 6, 2019
2 parents b0817cc + bea27dc commit 55e523c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
9 changes: 1 addition & 8 deletions core/lib/spree/core/validators/email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,9 @@ class EmailValidator < ActiveModel::EachValidator
EMAIL_REGEXP = /\A([^@\.]|[^@\.]([^@\s]*)[^@\.])@([^@\s]+\.)+[^@\s]+\z/

def validate_each(record, attribute, value)
unless value =~ EMAIL_REGEXP
unless EMAIL_REGEXP.match? value
record.errors.add(attribute, :invalid, { value: value }.merge!(options))
end
end
end
end

# @private
EmailValidator = ActiveSupport::Deprecation::DeprecatedConstantProxy.new(
'EmailValidator',
'Spree::EmailValidator',
message: "EmailValidator is deprecated! Use Spree::EmailValidator instead.\nChange `validates :email, email: true` to `validates :email, 'spree/email' => true`\n"
)
36 changes: 18 additions & 18 deletions core/spec/lib/spree/core/validators/email_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ class Tester

let(:valid_emails) {
[
'valid@email.com',
'valid@email.com.uk',
'e@email.com',
'valid+email@email.com',
'valid-email@email.com',
'valid_email@email.com',
'valid.email@email.com'
]
'valid@email.com',
'valid@email.com.uk',
'e@email.com',
'valid+email@email.com',
'valid-email@email.com',
'valid_email@email.com',
'valid.email@email.com'
]
}
let(:invalid_emails) {
[
'invalid email@email.com',
'.invalid.email@email.com',
'invalid.email.@email.com',
'@email.com',
'.@email.com',
'invalidemailemail.com',
'@invalid.email@email.com',
'invalid@email@email.com',
'invalid.email@@email.com'
]
'invalid email@email.com',
'.invalid.email@email.com',
'invalid.email.@email.com',
'@email.com',
'.@email.com',
'invalidemailemail.com',
'@invalid.email@email.com',
'invalid@email@email.com',
'invalid.email@@email.com'
]
}

it 'validates valid email addresses' do
Expand Down

0 comments on commit 55e523c

Please sign in to comment.