Class: AmericanDateParsing::AmericanDateValidator

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

Defined Under Namespace

Classes: Validation

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/american_date_parsing.rb', line 56

def validate_each(record, attribute, value)
  Validation.new({
    value:   record.read_attribute(attribute),
    raw:     record.send(:"_raw_#{attribute}"),
    options: options
  }).errors.each do |error, opts|
    opts = opts.respond_to?(:keys) ? opts : {}
    record.errors.add(attribute, error, opts)
  end
end