Class: DateValidator

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

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/dataclips.rb', line 5

def validate_each(record, attribute, value)
  return unless value.present?
  begin
    Date.parse(value)
  rescue ArgumentError
    record.errors[attribute] << :invalid
  end
end