Method: ActiveModel::Validations::FormatValidator#validate_each

Defined in:
lib/active_model/validations/format.rb

#validate_each(record, attribute, value) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/active_model/validations/format.rb', line 10

def validate_each(record, attribute, value)
  if options[:with]
    regexp = resolve_value(record, options[:with])
    record_error(record, attribute, :with, value) unless regexp.match?(value.to_s)
  elsif options[:without]
    regexp = resolve_value(record, options[:without])
    record_error(record, attribute, :without, value) if regexp.match?(value.to_s)
  end
end