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

Fix French PhoneNumber regexp #117

Merged
merged 1 commit into from
Sep 25, 2019
Merged

Fix French PhoneNumber regexp #117

merged 1 commit into from
Sep 25, 2019

Conversation

michalbundyra
Copy link
Member

Fixes #85

@michalbundyra michalbundyra added this to the 2.9.1 milestone Sep 23, 2019
@@ -13,7 +13,7 @@
'national' => [
'general' => '/^[124-9]\\d{8}|3\\d{3}(?:\\d{5})?$/',
'fixed' => '/^[1-5]\\d{8}$/',
'mobile' => '/^(?:[6-7]\\d{8}|7[5-9]\\d{7})$/',
'mobile' => '/^(?:700\\d{6}|6\\d{8}|7[3-9]\\d{7})$/',
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why the regex pattern differs from the Google library? Or did I miss something?

<nationalNumberPattern>
700\d{6}|
(?:
  6\d|
  7[3-9]
)\d{7}
</nationalNumberPattern>

https://github.com/google/libphonenumber/blob/v8.10.19/resources/PhoneNumberMetadata.xml#L9361-L9367

Copy link
Member Author

@michalbundyra michalbundyra Sep 24, 2019

Choose a reason for hiding this comment

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

@froschdesign The result is the same:

  • in google library we have: a|((b|c)d)
  • in PR we have a|e|f, where e = bd and f = cd.

Copy link
Member

Choose a reason for hiding this comment

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

It is this same result, but why not copy the pattern from the reference?

I want to go one step further: we need an update script for all regex patterns because there are more old and outdated patterns in this library. This means, it would result in copying.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we use it as the reliable source for all patterns? If so we can write a simple script to update patters, because right now I am super confused with so many regexp... For example I've also noted that we have more rules/countries in the library than it is in the google (we do have XK - Kosovo, and it is not present there).

Copy link
Member

Choose a reason for hiding this comment

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

Or we simplify the process and use an external library: libphonenumber for PHP

Copy link
Member Author

Choose a reason for hiding this comment

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

@froschdesign I guess, it will be for v3 - where we can change the approach completely, use the external library or use reliable source for all patterns.

michalbundyra added a commit that referenced this pull request Sep 25, 2019
michalbundyra added a commit that referenced this pull request Sep 25, 2019
michalbundyra added a commit that referenced this pull request Sep 25, 2019
@michalbundyra michalbundyra merged commit 88f3dbe into zendframework:master Sep 25, 2019
michalbundyra added a commit that referenced this pull request Sep 25, 2019
@michalbundyra michalbundyra deleted the hotfix/fr-phone-number branch September 25, 2019 15:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong pattern for french mobile phone
2 participants