Forum: Ruby on Rails validates_format_of before type_cast?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Steve R. (Guest)
on 2006-03-17 03:16
(Received via mailing list)
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 topic is locked and can not be replied to.