Class: UffizziCore::EmailValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/uffizzi_core/email_validator.rb

Constant Summary collapse

EMAIL_REGEXP =
/\A([^@\s<>]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.freeze

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



6
7
8
# File 'app/validators/uffizzi_core/email_validator.rb', line 6

def validate_each(record, attribute, value)
  record.errors.add(attribute, (options[:message] || :invalid)) unless value&.match?(EMAIL_REGEXP)
end