Class: EmailAddressValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/validator/email_address_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/validator/email_address_validator.rb', line 5

def validate_each(record, attribute, value)
  if options[:format]
    raise ArgumentError, "Don't use deprecated :format option. Use :with instead"
  end

  rules = Array(options[:with] || [])
  rules << build_default_rule if rules.empty?

  invalidate(record, attribute) unless all_rules_pass?(rules, value)
end