Re: Date Field Validation

Wayne Molina
Thu, 22 May 2008 13:58:46 -0000

Only way I know how to do this is to add your own validate method e.g.:

# in your model...
def validate
   errors.add(:start_date, "must be less than the end date") if
start_date >= end_date
end

There might be a helper to do this, but at the time I wasn''t aware of
one so this is how I did it ;-)

Hope this helps.

- Wayne

On May 22, 2008, at 3:09 AM, mrbless wrote:

>
> I have to fields in database start_date and end_date. What I want to
> validate is that start_date must  be less than end_date. I want the
> model level validation . Please help me.
>
> >