Comments (7)
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
I think that seems sensible.
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.
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 libphonenumber
- a phone number parsing, validation & formatting library written by Google.
We could potentially use elibphonenumber
to:
- Produce different formatted outputs (national phone number style, international style, e164, RFC3966, etc).
- Parse example phone numbers, then return the numbers chunked into their parts
- Retrieve the expected cost to call the number
- Probably lots more
If we go down the elibphonenumber
route, we can do this across many locales automatically.
Thoughts?
from faker.
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.
from faker.
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:
- Country Code (equivalent to area code I guess)
- National Destination Code (equivalent to exchange code I guess)
- Subscriber Number
Subscriber Number and National Destination Code make up what's called the Significant number.
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!
from faker.
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 en_UK
& en_US
. it should on one hand work with all en
s but also pick US/UK
when available. Sadly I don't have enough time to do that 😞
from faker.
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.
from faker.
@igas do you have any interest in E.164 numbers? I'd be happy to submit a PR when I get a chance.
from faker.
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.
from faker.
Related Issues (20)
- New release? HOT 1
- Problems when instantiating Faker in iex, I followed the documentation guide but it didn't help me much, can someone help me, I'm using Phoenix Framework HOT 2
- Faker.Name.PtBr.first_name/0 is undefined HOT 2
- Avatar url is redirected HOT 1
- Virgin Islands extra split
- Faker.Phone.EnUs.phone() produces invalid phone numbers HOT 2
- Feature request: Timezone
- Utilities for non-deterministic data generation
- Compile issue with Elixir 1.13 HOT 5
- invalid bidirectional formatting character in string: \u202A HOT 2
- compile error on elixir latest 1.13.12 HOT 2
- Faker.Blockchain.Ethereum.address/0 may return invalid addresses HOT 1
- Option to make any generated data unique HOT 1
- Faker.Vehicle.vin() does not always generate valid VINs
- feature: increase API compatibility with FakerElixir
- Release new version HOT 2
- Dependency Dashboard
- Faker.Date.date_of_birth() is failing on 29/2 HOT 5
- Faker.Date.date_of_birth() generates invalid dates when called on a leap date HOT 2
- Compile warnings with Elixir 1.17 rc
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from faker.