-
Notifications
You must be signed in to change notification settings - Fork 217
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
Faker.Phone API #44
Comments
I think that seems sensible.
The problem is that in order for UK phone numbers to be truely valid, they actually follow quite a specific pattern (See here for more info - parts of the number denote different areas of the UK, prefixes define different types of phone number, they can have different lengths depending on the type of number, etc etc). Because of this, Faker.format/1 has limited use. What we can use it for, is filling in the blanks after we choose a number format "template", such as in your example. It might be worth noting, I've begun maintaining a project called elibphonenumber, which is an Erlang NIF wrapper of We could potentially use
If we go down the Thoughts? |
Hey @igas @johnhamelink, I spent some time reading/investigating about telephone numbers and came across E.164 which basically states that a phone number consists of mainly three parts:
According to what I described above, I was thinking if it would be a good approach to have a separation of concerns here: the generation of the phone number in one side (without any specific format, just the sequence of digits) and have an extra set of rules to actually format the phone number according to the locale, because as @johnhamelink mentioned in the previous comment, in the UK phones are valid only if they follow a specific pattern, which might also be the case for all other countries. I'm by no means a telephone number expert 😁 just was dropping my suggestion here; let me know what you think! |
I would love to see a phone number module! Hmm I just saw this after I posted: https://github.com/igas/faker/blob/master/lib/faker/phone/en_us.ex Perhaps the README file just needed to be updated. |
well, we want to make it right, and I think first we need to do before it, decide how we'll manage langs and locales. Like |
Having the E.164 format would be awesome. Anytime you use a calling service (i.e. Twilio) you need to use this format. It's a pretty common use case. |
@igas do you have any interest in E.164 numbers? I'd be happy to submit a PR when I get a chance. |
Hi @anthonator I'm not very familiar with this standard, but I would be happy to look at it, we can always prefix it if we decide not to make it default one. PR is welcome. |
Hey folks,
I thinking about API for phones, here is my thoughts:
number/0
as general entry for mobile/landline numbers;cell_number/0
&mobile_number/0
;landline_number/0
;area_code/0
exchange_code/0
subscriber_number/0
extension/0
In some cases arity can be 1 cause of rules length of
subscriber_number
based onarea_code
etcReasons behind separation is sometimes number split in db or UI.
I prefer to use
Faker.format/1
there it is possible, because ideas of faker is to provide wide range of real world data (see Russian example below), so phone numbers is not just sequence of number and rules, but also style of formatting. Here is an example of code https://github.com/igas/faker/blob/0eb4aa3334e97e8a9ce41207934d1d631c92cc51/lib/faker/phone/en_gb.ex#L48-L55And here is example from St. Petersburg, Russia of the same number how it can be written:
I'll be glad to discuss this before 0.7 release and decide API. Any thoughts, suggestions? Pros/cons?
/cc @vforvova @johnhamelink @devshane @efexen @saulecabrera @awanninger
The text was updated successfully, but these errors were encountered: