Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

fix redundance errors "The input does not appear to be a valid date" show twice #2633

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/Zend/Validator/Date.php
Expand Up @@ -128,7 +128,7 @@ public function isValid($value)
// and still return a DateTime object
$errors = DateTime::getLastErrors();

if (false === $date || $errors['warning_count'] > 0) {
if ($errors['warning_count'] > 0) {
$this->error(self::INVALID_DATE);
return false;
}
Expand Down
14 changes: 14 additions & 0 deletions tests/ZendTest/Form/View/Helper/FormRowTest.php
Expand Up @@ -305,4 +305,18 @@ public function testShowErrorInRadio()
$markup = $this->helper->__invoke($element);
$this->assertContains('<ul><li>Error message</li></ul>', $markup);
}

public function testErrorShowTwice()
{
$element = new Element\Date('birth');
$element->setFormat('Y-m-d');
$element->setValue('2010-13-13');

$validator = new \Zend\Validator\Date();
$validator->isValid($element->getValue());
$element->setMessages($validator->getMessages());

$markup = $this->helper->__invoke($element);
$this->assertEquals(2, count(explode("<ul><li>The input does not appear to be a valid date</li></ul>", $markup)));
}
}