Adds support for India, Canada and much more #22

wants to merge 94 commits into

Area code formats now specified so that countries that share a country code can be supported, and invalid area codes (ex: 555 in North America) are recognized as invalid

Local number formats also specified. Allows for better country detection if the country differs from the default country code.

Parsing largely rewritten to better identify countries on parse.

Tests now clear global data between tests (default_country_code & default_area_code were being persisted).

German numbers are now parsed correctly.


There is already a 1.1 version, it's here: but not on GitHub. We are having our own issue with the gem as well.. I am hoping this is still maintained?


+1 for merging this.

Our testing shows that this new version handles US numbers better than the upstream. e.g. 18005551212 != +118005551212, #parse("").to_s doesn't return "" but nil. Several other tests behaving and parsing as expected.


+1 for merging this.

Would love to have the Canada country code supported here as well.

grempe-thrillcall and others added some commits Apr 3, 2012
@grempe-thrillcall grempe-thrillcall Add support for additional toll-free numbers in the US.

Area codes 800 since 1967, 888 (since 1996), 877 (since 1998), 866
(since 2000) and 855 (since 2010). Area codes reserved for future
expansion include 844, 833, 822, 880 through 887, and 889.

See :
Wesley Moxam Merge pull request #1 from thrillcall/800_numbers
Add support for additional toll-free numbers in the US.
@feldpost feldpost Support for non-geographic area codes
456: International inbound
500: Follow me numbers
533: Personal Communications Services
544	Personal Communications Services
566	Personal Communications Services
700	Carrier-specific services (generally not toll-free)
710	U.S. Federal Government (authorized users only)
Wesley Moxam Merge pull request #2 from feldpost/master
Support for non-geographic area codes
@wmoxam wmoxam Adds Aregentina, Costa Rica, Ethiopia and Tonga 53d7102
@wmoxam wmoxam Adds Zimbabwe aa2ca12
@wmoxam wmoxam Adds Israel fa7a0b0
@wmoxam wmoxam Adds Afganistan 0d88aaf
@wmoxam wmoxam Adds Albania c057621
@wmoxam wmoxam Adds Algeria 63bdb33
@wmoxam wmoxam Adds Austria 65f0edd
@wmoxam wmoxam Adds Austria, Bulgaria, Brazil and Belize 1732467
@wmoxam wmoxam Fixes carr#24
Includes test authored by activefx from here: activefx@e62349b
@wmoxam wmoxam Forgot to add these tests 6f02b0d
@kristianmandrup kristianmandrup added norway and improved DK 21afe53
@wmoxam wmoxam Adds tests for Denmark and Norway. Fixes loading problem for Norway c9e2260
@wmoxam wmoxam Adds Czech Republic & Cyprus fad2f5b
@wmoxam wmoxam Adds Ecuador, Estonia, Finland & El Salvador 8f03e0a
@wmoxam wmoxam Adds Belarus + forgotten tests 5b41517
@espen espen char_3_code should be string. Gave nil for Norway, should be "NO".
test for Norwegian mobile nr, specyfing country_code in parser but no code in input value
@wmoxam wmoxam More comprehensive parsing test c5891cc
@wmoxam wmoxam Adds Georgia, Greece, Guam and Guatemala 0af7d07
@wmoxam wmoxam Whoops, screwed up checking in tests :p fd7bf54
@kwilcox kwilcox Adds UAE (United Arab Emirates) 36b3b04
Wesley Moxam Merge pull request #5 from kwilcox/master
Adds UAE support
@g1smd g1smd Additional tests for GB number ranges.
Additional GB number ranges and formats not previously tested. Introduces numbers in 4+5, 5+5, 5+4 and 3+6 format.

Corrects that 873 is not freefone.
@g1smd g1smd Fix RegEx errors such as unnecessary pipes and commas. Optimise RegEx…
… pattern character groups.

|456[7]?|  simplifies to  |4567?|
A character group is not needed for a single character.

[1-7,8-9]  simplifies to  [1-78-9]   then to  [1-9]
The comma should not be used in a character group unless you want to match a literal comma.
@g1smd g1smd Fix GB area code RegEx pattern to include additional number types and…
… better restrict matches to valid ranges.
@g1smd g1smd Fixes to various RegEx patterns. 10a73e8
@g1smd g1smd Optimise RegEx patterns. 31e9a30
@g1smd g1smd When the international_dialing_prefix data was first imported, it app…
…ears to have been done as "integer" instead of "string" as all leading-zero data is missing from every item. Fixing entries that should be "00", and others.
@g1smd g1smd When international_dialing_prefix data was first imported (it looks l…
…ike from perhaps the wikipedia page listing these codes), many countries are detailed with very old data not the current situation.
@g1smd g1smd Optimise RegEx patterns. 85a4e3b
@g1smd g1smd Fix typo. 8844eb6
Wesley Moxam Merge pull request #6 from g1smd/master
Fix GB and other data. Additional GB tests. Fix international_dialing_prefix data. Fix RegEx patterns.

12 five-digit area codes, 500, 55, 56 were missing. The 3xx, 7xxx, 8xx, 9xx patterns were overly broad.


This "375:" line is an error and should be replaced with the US RegEx pattern.


Accidental change: "1" should be "1a" as before.


The extra "+375" is also a typo, and the two lines after it are duplicates of two of the lines you just added.

What happened originally is that the US RegEx was accidentally replaced by "375".

You have fixed by adding three lines in, so now there are three redundant lines.

Update coming in a few moments...

The US RegEx wasn't "removed". It was replaced by "375" in quotes, by accident.

Issue #7 reverses that as well as removing the unwanted duplicated lines added in 279ba74.


The US RegEx should be here in place of the "375" after the international_dialing_prefix line.


The above three lines have been added in error and are in the wrong place.

Two of the lines incorrectly duplicate data that was already correct and in the right place.

Wesley Moxam and others added some commits Aug 28, 2012
Wesley Moxam Merge pull request #7 from g1smd/master
Restore US RegEx and remove the "375" that was in its place.
@wmoxam wmoxam Don't raise parse exceptions on .valid? 943ed51
@wmoxam wmoxam Fixes parsing problems when there is a default country set 698800d
@wmoxam wmoxam Fixes Egyptian number parsing e79a584
@wmoxam wmoxam Stop the "no tests were specified" nonsense 81714db
@wmoxam wmoxam whoops, these aren't needed 17b9463
@wmoxam wmoxam Rename to 'Phonie' to avoid name clash with original gem. This will n…
…ever be merged in :/
@wmoxam wmoxam Merge branch 'master' of 8421cef
@wmoxam wmoxam More renaming e97661c
@wmoxam wmoxam Adds Latvia 47327de
@wmoxam wmoxam ignore vim swap files d8a5abd
@wmoxam wmoxam Adds Lithuania 7e6599e
@wmoxam wmoxam Adds support for Russia 685aa4e
@wmoxam wmoxam removes tmp file 837b0cd
@wmoxam wmoxam Adds Luxembourg 7742ecf
@sagmor sagmor Move development dependencies to gemspec 4b6fc15
@sagmor sagmor Add Chilean number support 4640460
@sagmor sagmor Add phone active model validations 93fc90e
@sagmor sagmor Don't loose extension on number formating e099147
@sagmor sagmor Add phone validation locales 66e1c88
@wmoxam wmoxam Fixes mobile parsing regex, leading zero shouldn't exist 2b1e0a6
@wmoxam wmoxam Adds Italian number support fa5b11e
@wmoxam wmoxam Updates countries list 493e1be
@wmoxam wmoxam Merge branch 'master' of
@wmoxam wmoxam minor refactor 810243d
@wmoxam wmoxam Adds a tool to quickly add new countries 3867ea7
@wmoxam wmoxam Adds Armenia dc9c653
@wmoxam wmoxam Adds Azerbaijanwq c315c48
@wmoxam wmoxam Adds Bahamas 4de77c7
@wmoxam wmoxam Adds Bahrain d704047
@wmoxam wmoxam Bump version for release fb91316
@wmoxam wmoxam Ignore undo files c964050
@wmoxam wmoxam Adds Ireland d5aaaf3
@wmoxam wmoxam Makes generator tool more robust baaa48f
@wmoxam wmoxam Adds New Zealand ce1f288
Wesley Moxam Adds support for Spain baed741
Wesley Moxam Prepare for release f566721
@wmoxam wmoxam closed this Mar 3, 2013

throwback to 2013! Curious if this newline was intentional?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment