fcevado / phone Goto Github PK
View Code? Open in Web Editor NEWElixir phone number parser for numbers in international standard.
License: Other
Elixir phone number parser for numbers in international standard.
License: Other
parser(:au, "61")
hi!
Thanks for your library, it seems great :)
I was trying to parse mobile phones from Spain, but it doesn't work (I think)
Phone.parse "+34600111111"
{:error, "Not a valid phone number."}
Is that expected and only work for landlines?
Thanks!
Improve tests and reorganize tests structure.
Create test helpers to reduce repetitive code.
Hi,
I've noticed that parse/2
function has incorrect spec:
@spec parse(String.t(), Atom.t()) :: {:ok, Map.t()}
@spec parse(pos_integer, Atom.t()) :: {:ok, Map.t()}
@spec parse!(String.t(), Atom.t()) :: Map.t()
@spec parse!(pos_integer, Atom.t()) :: Map.t()
country_parser()
It can return different result on error:
iex(4)> Phone.parse("12345678a", :ee)
{:error, "Not a valid phone number."}
This can be observed on version 0.5.1
I am having an issue getting irish phone numbers to parse correctly. I'm not sure what part of the phone number is the "area code", but here are some sample phone numbers.
+353 1 276 1923 - McDonald's, Bray, County Wicklow, Ireland
+353 402 39874 - McDonald's, Arklow, County Wicklow, Ireland
+353 1 872 4487 - McDonald's, 62 O'Connell Street Upper Dublin Dublin 1 O'Connell Street Upper, North City, Dublin 1, Ireland
Also what do you think about creating a test file for each country with sample phone numbers in it? For example, Ireland's tests would be in test/phone/ie_test.exs
.
While trying to parse a brazilian mobile phone number (2-digit country code + 2-digit local area code + 9-digit phone number), I've got this error:
Phone.parse("+5511912345678")
#=> {:error, "Not a valid phone number."}
I was wondering if you'd considered a feature that would "turn off" area code checking in certain environments via a configuration option. I typically use invalid phone numbers (ex. +1-555-555-5555) in testing intentionally to avoid the chance of accidentally sending out a real SMS or telephone call. Invalid phone numbers are also used by Twilio for testing (https://www.twilio.com/docs/api/rest/test-credentials). I think it would be valuable to have this feature for testing purposes.
Is this something you would consider adding to the library?
~r/^(244)()(9)/
Numbers in The Netherlands can now be an extra digit longer.
California has 2 new NPAs: 640 and 820.
PR coming soon.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.