-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix Validator\PhoneNumber with E.123/E.164 international numbers. #5150
Fix Validator\PhoneNumber with E.123/E.164 international numbers. #5150
Conversation
Related to #4645? |
} | ||
|
||
// Check for existence of international double-O prefix | ||
elseif (('00' . $countryPattern['code']) == substr($value, 0, $codeLength + 2)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PSR-2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pff.. there goes readability out of the window....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be improved by introducing explaining variables, maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah mate, waste of memory. I'd do an overhaul but don't have enough time... I've put a comment block above it all, hope you like it.
bump Merge or discuss it please. |
This is something I need myself, so I'll try to take a look in the next few days. |
* 2) International double-O prefix | ||
* 3) Bare country prefix | ||
*/ | ||
if (('+' . $countryPattern['code']) == substr($value, 0, $codeLength + 1)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this should be handled by filtering. I understand why it is there but you should filter our characters like this; because then why not have separators between digits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because plus sign is part of the standard Mike :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or put another way, 0048123123123
and +48123123123
and 48123123123
are equivalent, correct, absolute, international phone numbers.
@Thinkscape this looks good; just the one small cleanup and should be ready to merge 👍 |
…develop Forward port #5150
This fixes validation for international numbers such as:
More info on international phone number formats here