fzaninotto / Faker

Faker is a PHP library that generates fake data for you
MIT License
26.78k stars 3.58k forks source link

Feature: phoneNumber without extension (en_US) #1909

Open MGatner opened 4 years ago

MGatner commented 4 years ago

After running into this with the second major identity provider (Stripe first, now Google Firebase) I believe and option for a US phone number that never includes an extension is in order. Both of these providers occasionally reject phone numbers generated by Faker\Provider\en_US\PhoneNumber because of the length of inclusion of the "x".

mikk150 commented 4 years ago

I do not think that this should be fakers job, But you can use libphonenumber to fix it in your code

MGatner commented 4 years ago

That works but adds an entire validation library. It may or may not be Faker's job but the phoneNumber provider is already pretty sparse so it doesn't seem like a bad addition. Other providers break the components of the data into parts, e.g.: streetName, streetSuffix, streetAddress so you can fake the portion(s) needed for a particular scenario. This would essentially be the same thing for phone numbers, especially considering that extensions are non-standard.