Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e164PhoneNumber() generates invalid french Phone Numbers #531

Closed
MedericL-cgi opened this issue Oct 31, 2022 · 8 comments
Closed

e164PhoneNumber() generates invalid french Phone Numbers #531

MedericL-cgi opened this issue Oct 31, 2022 · 8 comments

Comments

@MedericL-cgi
Copy link

Summary

Similar issue : #332
Using e164PhoneNumber(), an invalid number is created for fr_FR. The generated phone numbers that start with 0 are invalid.
Ex : +330123456789

Versions

Version
PHP 8.1.11
fakerphp/faker 1.20.0

Self-enclosed code snippet for reproduction

$faker = FakerFactory::create();

dump($faker->e164PhoneNumber());

Expected output

number with +33[1-9]#########

Actual output

number with +33[0-9]#########

Source :
https://en.wikipedia.org/wiki/Telephone_numbers_in_France

@stale
Copy link

stale bot commented Nov 22, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions.

@MedericL-cgi
Copy link
Author

In case someone find this thread, we don't use 'e164PhoneNumber' anymore.
Instead, we use <regexify(((+)33((?6\d|7[3-9])\d{7})> in alice fixtures files.

@stale stale bot removed the lifecycle/stale label Nov 28, 2022
@mergeMarc
Copy link

I noticed the same with invalid swiss (de_CH) phone numbers. Would be nice if faker would offer more strict phone number generation.

@DvDty
Copy link

DvDty commented Dec 14, 2022

@mergeMarc Have you tried generating a number via numerify()?

@mergeMarc
Copy link

I could use numerify but only with the last few digits being random. The application i generate fixtures for has more strict validation (with libphonenumber-for-php) so things like area codes also need to be valid.

Using numerify would definitely be a valid workaround if only a smaller subset of possible phone numbers is needed (also randomly selecting from multiple numerify inputs). Probably less expensive than some regexify stuff too.

@stale
Copy link

stale bot commented Dec 30, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions.

@mergeMarc
Copy link

I would still be interested in this. Only issue i could see is that this would require a full on reverse regex type of solution to generate phone numbers based on commonly used metadata (like googles libphonenumber). So it might be overkill for some use cases.

My current workaround uses a reverse regex library with a static regex to generate plausible phone numbers for a country.
Example regex for swiss phone numbers (extracted from libphonenumber):

\+41((2[12467]|3[1-4]|4[134]|5[256]|6[12]|[7-9]1)\d{7}|7[35-9]\d{7})

@stale stale bot removed the lifecycle/stale label Jan 4, 2023
@stale
Copy link

stale bot commented Jan 22, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions.

@stale stale bot closed this as completed Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants