Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Fix Validator\PhoneNumber with E.123/E.164 international numbers. #5150

Conversation

Thinkscape
Copy link
Member

This fixes validation for international numbers such as:

+48 601 123 456
00 248 2510123

More info on international phone number formats here

@localheinz
Copy link
Member

Related to #4645?

}

// Check for existence of international double-O prefix
elseif (('00' . $countryPattern['code']) == substr($value, 0, $codeLength + 2)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PSR-2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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....

Copy link
Member

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?

Copy link
Member Author

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.

@Thinkscape
Copy link
Member Author

bump

Merge or discuss it please.

@EvanDotPro
Copy link
Member

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)) {
Copy link
Contributor

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.

Copy link
Member Author

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 :-)

Copy link
Member Author

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.

@mwillbanks
Copy link
Contributor

@Thinkscape this looks good; just the one small cleanup and should be ready to merge 👍

mwillbanks pushed a commit that referenced this pull request Oct 21, 2013
@Maks3w Maks3w mentioned this pull request Oct 21, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants