diff --git a/core/lib/spree/core/validators/email.rb b/core/lib/spree/core/validators/email.rb index 6e73d02bf24..a519aabb52a 100644 --- a/core/lib/spree/core/validators/email.rb +++ b/core/lib/spree/core/validators/email.rb @@ -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" -) diff --git a/core/spec/lib/spree/core/validators/email_spec.rb b/core/spec/lib/spree/core/validators/email_spec.rb index db2730cced6..7ab4843a362 100644 --- a/core/spec/lib/spree/core/validators/email_spec.rb +++ b/core/spec/lib/spree/core/validators/email_spec.rb @@ -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