Validating dates in rails
For example, if I enter February 31st 2009 in my view, when I use in my controller, it converts it to "March 3rd 2009", which my model then sees as a valid date, which it is, but it is incorrect.I would like to be able to do this validation in my model.
I found this "Date validation" that discusses the problem but it never was resolved.
However, there is an issue with most ORM/ODMs which does not allow 100% date/time validation by default.
Specifically, when you assign an invalid date/time value to an attribute, most ORM/ODMs will only store a nil value for the attribute.
I have tried three methods: 1) date_validator gem I used the following code (after installing the gem): This worked well and passed all my tests, but the drawback is that you only get one error message.
I would have liked separate error messages for the case when the date is in the future, when it is too long ago and when the input is not a date.