aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/validators/email_validator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/test/validators/email_validator.rb')
-rw-r--r--activemodel/test/validators/email_validator.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activemodel/test/validators/email_validator.rb b/activemodel/test/validators/email_validator.rb
index cff47ac230..dda0c4773c 100644
--- a/activemodel/test/validators/email_validator.rb
+++ b/activemodel/test/validators/email_validator.rb
@@ -1,6 +1,8 @@
+require 'active_support/core_ext/regexp'
+
class EmailValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << (options[:message] || "is not an email") unless
- value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
+ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i.match?(value)
end
-end \ No newline at end of file
+end