Issues

ZF-2762: When creating zend_form with config and validating a date field, it throws exception under certain circumstances.

Description

When creating zend_form with config and validating a date field, it throws exception when the file contained something like 'asdasda' -" No date part in 'asdasda' found.", BUT when the field contained '2008-sdgsdg , i got a correct error message in form - "'2008-sdgsdg' is not of the format YYYY-MM-DD".

Comments

Please include the code you need to reproduce this issue.

The problem is not Zend_Form. Zend_Validate_Date expects the date to be in the format "YYYY-MM-DD" as returned in the errormessage. When you want to use a different format you must provide Zend_Validate_Date with the proper format. See the documentation for details.

Just to mention: "2008-sdgsdg" IS no correct date, so the returned message is right and expected behaviour.

maybe i wasnt clear enough on this ;-)

if you have date like "2008-sdgsdg" - it shows error - that is expected - yes it is not a correct date.

but if the date is like 'sdgsdg' ie. there is no valid part like 2008 in the other example we dont get to see the "is not of the format..." message, it throws exception " No date part in ... found." - that is defenately not expected behavior - if user types something stupid to form - he should see the the wrong format message from validator - not script exception... maybe i explained better what is the problem now :D

Matthew,

here is the fragment of config resposible for date field :

{quote} text0l_object_publish_start date {quote}

Poster has a point: validators shouldn't throw exceptions on invalid data, but should simply mark as invalid and set an appropriate error.

Re-marking as a Zend_Validate issue and assigning to Darby for 1.5.0RC2

I can't seem to reproduce having an exception thrown from {{Zend_Validate_Date::isValid()}} with latest trunk version. Committed data input values to the test suite with SVN r8571. Please feel free to reopen with the code needed to reproduce the issue.