Class: Medivo::DateValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Medivo::DateValidator
- Defined in:
- lib/support/validators.rb
Overview
A valid date for the orders is a little different that usual .. so take note ā%Y%m%dā has no slashes or dashes .. so a date is valid that looks like: ā20111202ā
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/support/validators.rb', line 24 def validate(record) for field in [:fields] value = record.attributes[field] date = Date.strptime(value, '%Y%m%d') rescue nil record.errors.add(field, "invalid #{field}. needs to be in '%Y%m%d' format") unless date end end |