Class: MdsDateValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/mds_date_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



3
4
5
6
# File 'app/validators/mds_date_validator.rb', line 3

def validate_each(record, attribute, value)
  return if value.is_a?(Date) # We store dates as Date's; don't validate if it is already a date.
  record.errors[attribute] << "A valid date in item #{attribute} is required for this assessment type." if Date.safe_parse(value).blank?
end