ZF-3337: Zend_Validate_Date: Incorrect error message


When you specify a custom date format to Zend_Validate_Date and subsequently call isValid(), if your date is of the correct format but an invalid date, the validator returns a message saying the date was in the incorrect format.

This is caused by using Zend_Date::isDate() and assuming a return value of false means the date is in the incorrect format when it could be in the correct format but not a valid date (e.g., 30 Feb of any year).


$validator = new Zend_Validate_Date('MM/DD/YYYY');

// Correctly returns true

// Returns false (correctly) with message "'02/30/2008' does not fit given date format" (incorrect)


But the message is right... A 30. February does NOT fit the given format.

What would you expect to get returned when you set 'DDD yyyy' and input "0 0" ? The returned message did not say that the given format is not correct, it returned that the input does not fit in the given format, which is correct.

My point is that the message "'02/30/2008' does not fit given date format" is misleading as a user may look at the message and be confident he inputed the date in the correct format, what he might not immediately realise is that 30 Feb is an invalid date; therefore, a message saying "'02/30/2008' is not a valid date" would give better feedback on the user's error that what is currently being returned.

Currently, I will get the same error message whether I inputed an invalid date in the correct format or inputted a 'date' in the incorrect format.

Changed returned message with r9613

Updating for the 1.6.0 release.