mirror of
https://github.com/Respect/Validation.git
synced 2024-06-08 08:42:15 +02:00
Update regex of "Phone" rule
Now regex also matches +1 (555) 555 5555
This commit is contained in:
parent
c013fac277
commit
191ee47fc0
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ class PhoneTest extends \PHPUnit_Framework_TestCase
|
|||
['5555555'],
|
||||
['555.5555'],
|
||||
['555 5555'],
|
||||
['+1 (555) 555 5555'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue