FinalCAD/csv_row_model

View on GitHub
lib/csv_row_model/validators/date_format_validator.rb

Summary

Maintainability
A
0 mins
Test Coverage
class DateFormatValidator < ActiveModel::EachValidator # :nodoc:
  def validate_each(record, attribute, value)
    Date.parse(value)
  rescue ArgumentError, TypeError
    record.errors.add(attribute, 'is not a Date format')
  end
end