Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Deprecated EmailValidator #3395

Merged
merged 2 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
JDutil marked this conversation as resolved.
Show resolved Hide resolved
'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