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

Issue Type: Bug Created: 2008-02-29T08:40:54.000+0000 Last Updated: 2008-03-21T16:25:37.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Marcin Lulek (ergo14) Assignee: Darby Felton (darby) Tags: - Zend_Validate

Related issues: Attachments:


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".


Posted by Matthew Weier O'Phinney (matthew) on 2008-03-05T10:43:48.000+0000

Please include the code you need to reproduce this issue.

Posted by Thomas Weidner (thomas) on 2008-03-05T11:01:24.000+0000

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.

Posted by Marcin Lulek (ergo14) on 2008-03-05T12:55:43.000+0000

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

Posted by Marcin Lulek (ergo14) on 2008-03-06T01:29:22.000+0000


here is the fragment of config resposible for date field :

{quote} text0l_object_publish_start date {quote}

Posted by Matthew Weier O'Phinney (matthew) on 2008-03-06T08:53:15.000+0000

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

Posted by Matthew Weier O'Phinney (matthew) on 2008-03-06T08:54:04.000+0000

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

Posted by Darby Felton (darby) on 2008-03-06T09:19:44.000+0000

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.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.