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

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
4 participants
Member

Thinkscape commented Sep 20, 2013

This fixes validation for international numbers such as:

+48 601 123 456
00 248 2510123

More info on international phone number formats here

Member

localheinz commented Sep 20, 2013

Related to #4645?

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

Thinkscape Sep 23, 2013

Member

What exactly ?

@Thinkscape

Thinkscape Sep 23, 2013

Member

Pff.. there goes readability out of the window....

@localheinz

localheinz Sep 23, 2013

Member

Could be improved by introducing explaining variables, maybe?

@Thinkscape

Thinkscape Sep 23, 2013

Member

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.

+ $this->assertTrue($this->validator->isValid($countryCodePrefixed));
+
+ // check fully qualified E.123/E.164 international variants
+ $fullyQualifiedDoubleO = '00'. $parameters['code'] . $value;
@localheinz

localheinz Sep 20, 2013

Member

before. missing (more down below).

Member

Thinkscape commented Oct 5, 2013

bump

Merge or discuss it please.

Member

EvanDotPro commented Oct 17, 2013

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)) {
@mwillbanks

mwillbanks Oct 17, 2013

Contributor

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.

@Thinkscape

Thinkscape Oct 17, 2013

Member

Because plus sign is part of the standard Mike :-)

@Thinkscape

Thinkscape Oct 17, 2013

Member

Or put another way, 0048123123123 and +48123123123 and 48123123123 are equivalent, correct, absolute, international phone numbers.

Contributor

mwillbanks commented Oct 17, 2013

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

mwillbanks added a commit that referenced this pull request Oct 21, 2013

@Maks3w Maks3w referenced this pull request Oct 21, 2013

Closed

General number format #5132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment