Date validation using pattern. Why?


there's a couple neat libraries for parsing/validating dates/times:

and your English is fine!

one of the basic principles of ruby/rails programming is to look for a
plugin, gem or lib (or maybe a pastie) of some sort for a well-defined
requirement before you spend 3 days and nights keying and mousing
away. People have thought of nearly everything .

This is making more sense now, my date field in my model is persisted
as a date in the database. From my understanding of all of your
posts, there is no way to validate the input because it is an instance
of a date, not an instance of a string. Therefore when ruby converts
the date to the ISO string, its not possible to get it into the format
I expect during the validation phase. Are there any formatting hooks
in RoR? In other words, can I register input and output formatters
(Similar to JSF in Java) so that dates aren't displayed with the ISO
format? Since my users will mostly be in the US, I don't want to
always have the format as yyyy-mm-dd. My users would much rather have
mm/dd/yyyy, so I would like to have that format as both the input and
output, then I can wrap it with a javascript calendar to make it the
input easy to use. I've tried Googling online for some documentation
outlining the request lifecycle of a RoR app, but I can't seem to find
what I need.


request lifecycle:


I think that the reason dates are stored in the database in ISO format
is to enable date comparisons.

"2007-10-19" > "2006-12-08"


"10/19/2007" < "12/08/2006"

But if the column type is time, date or datetime, ActiveRecord will
convert to and from Ruby Time and Date objects when you read and write
the record. You can then format as you wish using the strftime