Class: ATDIS::Validators::DateTimeValidator

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

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



15
16
17
18
19
20
# File 'lib/atdis/validators.rb', line 15

def validate_each(record, attribute, value)
  raw_value = record.send("#{attribute}_before_type_cast")
  if raw_value.present? && !value.kind_of?(DateTime)
    record.errors.add(attribute, "is not a valid date")
  end
end