This plugin gives ActiveRecord the ability to do stricter date checking.
class Person < ActiveRecord::Base
This will ensure that date_of_birth is a valid date. The date can be
initially as a string in any of the following formats:
“1 Jan 06”, or “1 Jan 2006”
“1/1/06” # Day / Month / Year
They will all be parsed into a date object before the model is saved. If
date has been set to an invalid string, eg “Meow”, an error is added to
model. Example (using Person as defined above):
p = Person.new
p.date_of_birth = “1 Jan 2006”
p.save # true
p.date_of_birth = “java is better than ruby”
p.save # false
In the final example, as I’m sure you are aware, the record failed to
not only because “java is better than ruby” is an invalid date, but more
importantly, because the statement is blatantly false.
Check it’s all working with:
rake test:plugins [or rake test_plugins if you are using Rails 1.0]
Suggestions, comments, problems are all welcome.