diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index a9bbad662..9d2553c3e 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -1462,10 +1462,11 @@ class ValidationTest extends CakeTestCase { $this->assertTrue(Validation::date('2008', array('y'))); $this->assertTrue(Validation::date('2013', array('y'))); $this->assertTrue(Validation::date('2104', array('y'))); + $this->assertTrue(Validation::date('1899', array('y'))); $this->assertFalse(Validation::date('20009', array('y'))); $this->assertFalse(Validation::date(' 2012', array('y'))); $this->assertFalse(Validation::date('3000', array('y'))); - $this->assertFalse(Validation::date('1899', array('y'))); + $this->assertFalse(Validation::date('1799', array('y'))); } /** diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index cb2aa8706..24b9bfa0f 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -278,7 +278,9 @@ class Validation { /** * Date validation, determines if the string passed is a valid date. - * keys that expect full month, day and year will validate leap years + * keys that expect full month, day and year will validate leap years. + * + * Years are valid from 1800 to 2999. * * ### Formats: * @@ -304,7 +306,7 @@ class Validation { } $month = '(0[123456789]|10|11|12)'; $separator = '([- /.])'; - $fourDigitYear = '(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))'; + $fourDigitYear = '(([1][8-9][0-9][0-9])|([2][0-9][0-9][0-9]))'; $twoDigitYear = '([0-9]{2})'; $year = '(?:' . $fourDigitYear . '|' . $twoDigitYear . ')';