mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Make year range validation less strict by default.
This commit is contained in:
parent
d6733e3ad1
commit
b188d670b7
2 changed files with 6 additions and 3 deletions
|
@ -1462,10 +1462,11 @@ class ValidationTest extends CakeTestCase {
|
||||||
$this->assertTrue(Validation::date('2008', array('y')));
|
$this->assertTrue(Validation::date('2008', array('y')));
|
||||||
$this->assertTrue(Validation::date('2013', array('y')));
|
$this->assertTrue(Validation::date('2013', array('y')));
|
||||||
$this->assertTrue(Validation::date('2104', 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('20009', array('y')));
|
||||||
$this->assertFalse(Validation::date(' 2012', array('y')));
|
$this->assertFalse(Validation::date(' 2012', array('y')));
|
||||||
$this->assertFalse(Validation::date('3000', 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 @@ class Validation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date validation, determines if the string passed is a valid date.
|
* 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:
|
* ### Formats:
|
||||||
*
|
*
|
||||||
|
@ -304,7 +306,7 @@ class Validation {
|
||||||
}
|
}
|
||||||
$month = '(0[123456789]|10|11|12)';
|
$month = '(0[123456789]|10|11|12)';
|
||||||
$separator = '([- /.])';
|
$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})';
|
$twoDigitYear = '([0-9]{2})';
|
||||||
$year = '(?:' . $fourDigitYear . '|' . $twoDigitYear . ')';
|
$year = '(?:' . $fourDigitYear . '|' . $twoDigitYear . ')';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue