[Validator] fixed error message for dates like 2012-02-31 (closes #4223)
This commit is contained in:
parent
03d22b74ec
commit
facbcdcf45
@ -48,12 +48,12 @@ class DateValidator extends ConstraintValidator
|
||||
|
||||
$value = (string) $value;
|
||||
|
||||
if (!preg_match(static::PATTERN, $value, $matches)) {
|
||||
if (!preg_match(static::PATTERN, $value, $matches) || !checkdate($matches[2], $matches[3], $matches[1])) {
|
||||
$this->setMessage($constraint->message, array('{{ value }}' => $value));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return checkdate($matches[2], $matches[3], $matches[1]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ class DateValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
public function testInvalidDates($date)
|
||||
{
|
||||
$this->assertFalse($this->validator->isValid($date, new Date()));
|
||||
$this->assertEquals('This value is not a valid date', $this->validator->getMessageTemplate());
|
||||
}
|
||||
|
||||
public function getInvalidDates()
|
||||
|
Reference in New Issue
Block a user