Class: DateFormatValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/csv_row_model/validators/date_format.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/csv_row_model/validators/date_format.rb', line 2

def validate_each(record, attribute, value)
  begin
    Date.parse(value.to_s)
  rescue ArgumentError
    record.errors.add(attribute, 'is not a Date format')
  end
end