Skip to content
Permalink
Browse files

Make year range validation less strict by default.

  • Loading branch information...
dereuromark committed Jul 26, 2014
1 parent d6733e3 commit b188d670b7181b5e6ace00522986aca2c2220bb8
Showing with 6 additions and 3 deletions.
  1. +2 −1 lib/Cake/Test/Case/Utility/ValidationTest.php
  2. +4 −2 lib/Cake/Utility/Validation.php
@@ -1462,10 +1462,11 @@ public function testDateY() {
$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')));
}
/**
@@ -278,7 +278,9 @@ public static function custom($check, $regex = null) {
/**
* 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 @@ public static function date($check, $format = 'ymd', $regex = null) {
}
$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 . ')';

0 comments on commit b188d67

Please sign in to comment.
You can’t perform that action at this time.