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



17
18
19
20
21
22
# File 'lib/atdis/validators.rb', line 17

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, ErrorMessage["is not a valid date", options[:spec_section]])
  end
end