Merge pull request #8576 from cakephp/issue-8567

Allow N11 exchange numbers as valid.
This commit is contained in:
Mark Story 2016-04-01 21:57:42 -04:00
commit 0a6a6c86c4
2 changed files with 2 additions and 4 deletions

View file

@ -2161,9 +2161,6 @@ class ValidationTest extends CakeTestCase {
$this->assertFalse(Validation::phone('1-(511)-999-9999'));
$this->assertFalse(Validation::phone('1-(555)-999-9999'));
// invalid exhange
$this->assertFalse(Validation::phone('1-(222)-511-9999'));
// invalid phone number
$this->assertFalse(Validation::phone('1-(222)-555-0199'));
$this->assertFalse(Validation::phone('1-(222)-555-0122'));
@ -2186,6 +2183,7 @@ class ValidationTest extends CakeTestCase {
$this->assertTrue(Validation::phone('1.(333).333-4444'));
$this->assertTrue(Validation::phone('1.(333).333.4444'));
$this->assertTrue(Validation::phone('1-333-333-4444'));
$this->assertTrue(Validation::phone('1-800-211-4511'));
}
/**

View file

@ -672,7 +672,7 @@ class Validation {
// Exchange and 555-XXXX numbers
$regex .= '(?!(555(?:\s*(?:[.\-\s]\s*))(01([0-9][0-9])|1212)))';
$regex .= '(?!(555(01([0-9][0-9])|1212)))';
$regex .= '([2-9]1[02-9]|[2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)';
$regex .= '([2-9]1[02-9]|[2-9][02-9]1|[2-9][0-9]{2})\s*(?:[.-]\s*)';
// Local number and extension
$regex .= '?([0-9]{4})';