class ActiveRecordDateFormatted::DateFormatValidator

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File lib/active_record_date_formatted/date_format_validator.rb, line 3
def validate_each(record, attribute, value)
  return false if value.blank?
  begin
    Date.strptime(value, I18n.t("date.formats.default"))
  rescue ArgumentError
    record.errors[attribute] << :invalid
  end
end