Support random and valid North American Numbering Plan phone numbers #2303
Labels
c: feature
Request for new feature
m: phone
Something is referring to the phone module
p: 1-normal
Nothing urgent
s: waiting for user interest
Waiting for more users interested in this feature
Milestone
Clear and concise description of the problem
This won't generate valid and random numbers though. At least not valid US/CA (aka the North American Numbering Plan, or those phones using the country code +1) phone numbers. A +1 number must broadly speaking follow the pattern:
There are three parts to a +1 number:
The line number can be any four digits (
\d{4}
). The first two triplets (area and branch) cannot start with the number 1 ([2-9]\d{2}
) and they cannot end with the two ones. Currently there is no way (that I can tell) to create valid +1 phone numbers with Faker. I can manually set the area and branch to a fixed number and just generate random line numbers, however for some use cases this is not acceptable (for example determining the area code).Suggested solution
I have two potential solutions.
faker.phone.number
output phone numbers that are proper and valid North American Numbering Plan numbers. This seems like the solution more inline with how faker is setup, as to the best of my knowledge most of the defaultfaker
API methods return US formatted data and if you wish to use say a Polish locale you need to import that separately.Alternative
No response
Additional context
Here is the wikipedia article on the North American Numbering plan: https://en.wikipedia.org/wiki/North_American_Numbering_Plan
The text was updated successfully, but these errors were encountered: