Update regex of "Phone" rule

Now regex also matches +1 (555) 555 5555
This commit is contained in:
RCooLeR 2017-07-19 23:14:21 +03:00 committed by Henrique Moody
parent c013fac277
commit 191ee47fc0
No known key found for this signature in database
GPG key ID: 221E9281655813A6
2 changed files with 2 additions and 1 deletions

View file

@ -15,6 +15,6 @@ class Phone extends AbstractRule
{
public function validate($input)
{
return !empty($input) && preg_match('/^[+]?([\d]{0,3})?[\(\.\-\s]?(([\d]{1,3})[\)\.\-\s]*)?(([\d]{3,5})[\.\-\s]?([\d]{4})|([\d]{2}[\.\-\s]?){4})$/', $input);
return !empty($input) && preg_match('/^[+]?([\d]{0,3})?\s?[\(\.\-\s]?(([\d]{1,3})[\)\.\-\s]*)?(([\d]{3,5})[\.\-\s]?([\d]{4})|([\d]{2}[\.\-\s]?){4})$/', $input);
}
}

View file

@ -93,6 +93,7 @@ class PhoneTest extends \PHPUnit_Framework_TestCase
['5555555'],
['555.5555'],
['555 5555'],
['+1 (555) 555 5555'],
];
}