1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/test/validators/email_validator.rb
Rafael Mendonça França e67fdc5aeb
Revert "Merge pull request #37504 from utilum/no_implicit_conversion_of_nil"
This reverts commit 4e105385d0, reversing
changes made to 62b4383909.

The change in Ruby that made those changes required was reverted in
8852fa8760
2019-12-09 11:50:39 -03:00

9 lines
300 B
Ruby

# frozen_string_literal: true
class EmailValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.match?(value)
record.errors.add(attribute, message: options[:message] || "is not an email")
end
end
end