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
# File 'lib/validator/email_address_validator.rb', line 5

def validate_each(record, attribute, value)
  rules = Array(options[:with] || [])
  if rules.empty?
    # We are using the old syntax, assume regular expressions
    rules = [build_rule_from_format(options[:format])]
  end

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