FinalCAD/csv_row_model

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

Summary

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