Comments (8)
Hi Declan,
Thanks for the sensible issue entry.
I discuss this issue in #37 and also #35. Checking E164 plausibility is discussed here: https://github.com/floere/phony/blob/master/README.textile#plausibility
In a nutshell: Phony only handles international numbers that conform to E164 or are normalizable to it. For example: https://github.com/floere/phony/blob/master/spec/lib/phony_spec.rb#L190-194.
Currently, I am debating whether to raise a useful error, but since I'd like Phony to be only for handling E164 numbers, I'm unsure.
One idea is to check the number first, something like:
Phony.normalize! number if Phony.plausible? number
Does that help?
from phony.
Thanks for the quick feedback floere.
I did not give the best example, which also illustrates the problem with plausible?().
Here we go, using '353' instead of '1'...
Phony.normalize! '353' if Phony.plausible? '353'
Giving the output...
"353[#<Phony::NationalCode:0x9d1a318 @national_splitter=#<Phony::
NationalSplitters::Variable:0x9d1acb4 @size=nil, @zero=\"0\",.
@mapped_ndc_min_length=1, @mapped_ndc_max_length=2, @ndcs={1=>[\"1\"], 2=>[\"21\",.
\"41\", \"42\", \"46\", \"49\", \"56\", \"58\", \"59\", \"65\", \"66\", \"71\",
\"74\", \"76\", \"90\", \"94\"]}>, @local_splitter=#<Phony::LocalSplitters::
Fixed:0x9d1a598 @format=[3, 14]>, @normalize=true>, #<Phony::NationalCode:0x9d198dc
@national_splitter=#<Phony::NationalSplitters::Variable:0x9d19e54 @size=nil,.
@zero=\"0\", @mapped_ndc_min_length=2, @mapped_ndc_max_length=3, @ndcs={2=>[\"22\",
\"23\", \"24\", \"25\", \"26\", \"27\", \"28\", \"29\", \"43\", \"44\", \"47\", \"48\",
\"52\", \"53\", \"54\", \"55\", \"62\", \"63\", \"64\", \"67\", \"68\", \"69\", \"93\",
\"94\", \"95\", \"96\", \"97\", \"98\", \"99\"], 3=>[\"402\", \"404\", \"502\", \"504\",
\"505\", \"506\", \"509\"]}>, @local_splitter=#<Phony::LocalSplitters::Fixed:0x9d19904
@format=[15]>, @normalize=true>, #<Phony::NationalCode:0x9d14cd8 @national_splitter=
#<Phony::NationalSplitters::Variable:0x9d1514c @size=nil, @zero=\"0\",
@mapped_ndc_min_length=2, @mapped_ndc_max_length=2, @ndcs={2=>[\"45\", \"51\", \"61\",
\"91\"]}>, @local_splitter=#<Phony::LocalSplitters::Fixed:0x9d14cec @format=[16]>,.
@normalize=true>, #<Phony::NationalCode:0x9d13fcc @national_splitter=#<Phony::
NationalSplitters::Variable:0x9d14b34 @size=nil, @zero=\"0\", @mapped_ndc_min_length=3,.
@mapped_ndc_max_length=3, @ndcs={3=>[\"800\"]}>, @local_splitter=#<Phony::
LocalSplitters::Fixed:0x9d14cec @format=[16]>, @normalize=true>, #<Phony::NationalCode:
0x9d13ab8 @national_splitter=#<Phony::NationalSplitters::Regex:0x9d13c70 @size=nil,.
@zero=\"0\", @regex=/^(8\\d).+$/>, @local_splitter=#<Phony::LocalSplitters::Fixed:
0x9d1a598 @format=[3, 14]>, @normalize=true>, #<Phony::NationalCode:0x9d13748
@national_splitter=#<Phony::NationalSplitters::None:0x9d1384c>, @local_splitter=#<
Phony::LocalSplitters::Fixed:0x9d1375c @format=[10]>, @normalize=true>]"
Basically I think that plausible?() is returning true but then normalize!() chokes on the processing.
from phony.
Thanks for the feedback. I understand the real problem now β plausible?
is not returning false
, as it should, but true
. I will look into it why that is so. Cheers!
from phony.
@theirishpenguin Thanks Declan. A fix is released in 1.7.3. Also see https://github.com/floere/phony/wiki/Contributors.
from phony.
That's great floere! I've retested the fix and it works great!
Thanks for the mention in the contributors file.
Agus go raibh mΓle maith agat :-)
Declan
from phony.
Great to hear! Due to the nature of its domain, Phony is a work in progress and I am very glad to get such good feedback to improve it. I am the last man to say it's finished or perfect, so your help is much appreciated.
Contributors: My pleasure β if you wish to be listed in the "Github contributors", just send your next bug report as a failing test in the tests. (Although I hope that there are no further bugs)
Also, if you find an Irish number that does not look ok, or if you happen to hear about changes in the Irish phone number system, I am very glad to hear about it here, as a pull request, or on twitter under "@Hanke".
Thanks! I really love languages, Gaeilge is in my top 10 :)
Florian
from phony.
Oops. Didn't see this message you left 2 months ago. Thanks again for all the work on this and I'll shout if I hear of any updates to the Irish phone number system (hopefully there won't be any for a while!).
Gaeilge is a great ol language. Though Ruby is my fav these days :)
Ciao,
Dec
from phony.
Hi Declan,
Thanks for the message!
Cheers,
Florian
from phony.
Related Issues (20)
- Phony.plausible? returns false for a valid Belgian mobile phone number HOT 4
- warning: Capturing the given block using Proc.new is deprecated; use `&block` instead HOT 2
- Phony.normalize('6502001382') returns '652001382' -- '0' was lost HOT 1
- Phony.plausible? returns false for a valid Belgian phone number HOT 2
- Numbering plan of Cote d'Ivoire/Ivory Coast has changed HOT 1
- Handle country codes for countries related to the united states with area code part of the country calling code +1-xxx HOT 3
- Globaltel Serbia phone numbers are not plausible
- Phony plausible? returns false for 3 digit locals with 3 digit NDC (German Numbers) HOT 5
- `false` is being inserted into formatted phone number, when no NDC is being used HOT 3
- Mauritan number definition does split but normalize HOT 3
- Samoa valid number that starts with "71" was not validated HOT 3
- Phony.plausible? returns false for valid Columbian numbers HOT 2
- Valid Italian phone number fails plausibility check HOT 2
- Proposal for "no RAM" mode HOT 4
- Nine digits Brazilian cellphone numbers HOT 2
- Dial code not added when the phone number has just the leading 00 but no actual dial code. HOT 2
- Valid Italian Landline numbers fails plausibility check HOT 1
- Validations failing for Vietnamese number HOT 2
- Valid phone numbers of Luxembourg don't pass the plausibility check HOT 2
- Number is normalized incorrectly in some cases
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 phony.