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



19
20
21
22
23
24
# File 'lib/atdis/validators.rb', line 19

def validate_each(record, attribute, value)
  raw_value = record.send("#{attribute}_before_type_cast")
  return unless raw_value.present? && !value.is_a?(DateTime)

  record.errors.add(attribute, ErrorMessage["is not a valid date", options[:spec_section]])
end