Validates_format_of before type_cast?

Often I need to do a one-off validation before Rails has had a chance to
convert. For example, a date. Is there a general mechanism to cause
validations to run on the raw input or do I have to resort to:

def validate
unless attributes_before_type_cast[‘date_of_loss’] =~
errors.add(‘date_of_loss’, ‘use the form: mm/dd/yyyy’)


(BTW: I know there is a date validation plugin)

View this message in context:
Sent from the RubyOnRails Users forum at

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs