telephone_number 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02f11c8fa7070815c05cde535d3edc3364a562de
4
- data.tar.gz: 0f275f02c5f79f178febfaa876a04348e31d6b13
3
+ metadata.gz: 6d1182623bbe38dba05f732f29020d92b4e3bf06
4
+ data.tar.gz: b27bc63b6dd33e0310ee271a89e08d9b9a4c7e8e
5
5
  SHA512:
6
- metadata.gz: 06f0513469c217c5823d72bf943b9ee2876f71d154f55961e6b36210346cc8a08fcba4edd78e3ea6f982c1b1a4a84186024bb6af048f9a74a63d0143c953ea6c
7
- data.tar.gz: 87ef4aaec4af3c8467b45a786ffc6c3746871689744c11b0bb3131248f380d33ed20cc5a5006296daa394c0f003ed10a775bcd2ad2a6c0864cb7ab24262f24d5
6
+ metadata.gz: 1c9df0dffe26550bfa71de2083dcaf9a8b45fa936a548e75f5fcf6c9cc7248016e366e1e3b38c3f9a8a74deae28b34b18c4dadd391c66ea83ebc723c7006ee8c
7
+ data.tar.gz: c6f5876994fadb4cc44095e311548309703ffcec06ef5661512ab1fe9416340cea732b95b18d2230ea10dd754ef21c810d9dbf75c42febc79f09f302143073e6
data/.hound.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  fail_on_violations: true
2
+
2
3
  ruby:
3
- config_file: .ruby.yml
4
+ config_file: .rubocop.yml
@@ -1,3 +1,5 @@
1
+ # These are all the cops that are enabled in the default configuration.
2
+
1
3
  Style/AccessModifierIndentation:
2
4
  Description: Check indentation of private/protected visibility modifiers.
3
5
  StyleGuide: '#indent-public-private-protected'
@@ -964,6 +966,8 @@ Style/ZeroLengthPredicate:
964
966
  Description: 'Use #empty? when testing for objects of length 0.'
965
967
  Enabled: true
966
968
 
969
+ #################### Metrics ###############################
970
+
967
971
  Metrics/AbcSize:
968
972
  Description: >-
969
973
  A calculated magnitude based on number of assignments,
@@ -1015,6 +1019,9 @@ Metrics/PerceivedComplexity:
1015
1019
  human reader.
1016
1020
  Enabled: true
1017
1021
 
1022
+ #################### Lint ##################################
1023
+ ### Warnings
1024
+
1018
1025
  Lint/AmbiguousOperator:
1019
1026
  Description: >-
1020
1027
  Checks for ambiguous operators in the first argument of a
@@ -1272,6 +1279,7 @@ Lint/UselessAccessModifier:
1272
1279
  Description: 'Checks for useless access modifiers.'
1273
1280
  Enabled: true
1274
1281
  ContextCreatingMethods: []
1282
+ MethodCreatingMethods: []
1275
1283
 
1276
1284
  Lint/UselessAssignment:
1277
1285
  Description: 'Checks for useless assignment to a local variable.'
@@ -1294,6 +1302,8 @@ Lint/Void:
1294
1302
  Description: 'Possible use of operator/literal/variable in void context.'
1295
1303
  Enabled: true
1296
1304
 
1305
+ #################### Performance ###########################
1306
+
1297
1307
  Performance/Casecmp:
1298
1308
  Description: >-
1299
1309
  Use `casecmp` rather than `downcase ==`, `upcase ==`, `== downcase`, or `== upcase`..
@@ -1400,7 +1410,9 @@ Performance/RedundantSortBy:
1400
1410
  Enabled: true
1401
1411
 
1402
1412
  Performance/RegexpMatch:
1403
- Description: 'Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`, `Regexp#===` or `=~` when `MatchData` is not used.'
1413
+ Description: >-
1414
+ Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`,
1415
+ `Regexp#===`, or `=~` when `MatchData` is not used.
1404
1416
  Enabled: true
1405
1417
 
1406
1418
  Performance/ReverseEach:
@@ -1447,6 +1459,8 @@ Performance/TimesMap:
1447
1459
  Description: 'Checks for .times.map calls.'
1448
1460
  Enabled: true
1449
1461
 
1462
+ #################### Rails #################################
1463
+
1450
1464
  Rails/ActionFilter:
1451
1465
  Description: 'Enforces consistent use of action filter methods.'
1452
1466
  Enabled: true
@@ -1569,6 +1583,8 @@ Rails/Validation:
1569
1583
  Description: 'Use validates :attribute, hash of validations.'
1570
1584
  Enabled: true
1571
1585
 
1586
+ #################### Security ##############################
1587
+
1572
1588
  Security/Eval:
1573
1589
  Description: 'The use of eval represents a serious security risk.'
1574
1590
  Enabled: true
@@ -1597,6 +1613,8 @@ Security/YAMLLoad:
1597
1613
  Reference: 'https://ruby-doc.org/stdlib-2.3.3/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
1598
1614
  Enabled: true
1599
1615
 
1616
+ #################### Bundler ###############################
1617
+
1600
1618
  Bundler/DuplicatedGem:
1601
1619
  Description: 'Checks for duplicate gem entries in Gemfile.'
1602
1620
  Enabled: true
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ inherit_from: .rubocop.default.yml
2
+
3
+ Style/StringLiterals:
4
+ EnforcedStyle: single_quotes
data/.travis.yml CHANGED
@@ -1,7 +1,9 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.1.0
5
- - 2.2.5
6
- - 2.3.0
4
+ - 2.0.0-p648
5
+ - 2.1.10
6
+ - 2.2.6
7
+ - 2.3.3
8
+ - 2.4.0
7
9
  before_install: gem install bundler -v 1.13.7
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 Adam Fernung
3
+ Copyright (c) 2017 MOBI Wireless Management
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
+ [![Code Climate](https://codeclimate.com/github/mobi/telephone_number/badges/gpa.svg)](https://codeclimate.com/github/mobi/telephone_number)
2
+
1
3
  # What is it?
2
4
 
3
- TelephoneNumber is global phone number validation gem based on Google's [libphonenumber](https://www.google.com) library. We're currently providing parsing and validation functionality and are actively working on formatting as well as providing extended data.
5
+ TelephoneNumber is global phone number validation gem based on Google's [libphonenumber](https://github.com/googlei18n/libphonenumber) library. We're currently providing parsing and validation functionality and are actively working on formatting as well as providing extended data.
4
6
 
5
7
  ## Installation
6
8
 
@@ -25,39 +27,44 @@ TelephoneNumber requires a country when parsing and validating phone numbers.
25
27
  **To validate a phone number:**
26
28
 
27
29
  TelephoneNumber.valid?("(555) 555-5555", "US") ==> false
28
-
29
- You can pass an optional array of keys to check the validity against.
30
+
31
+ You can pass an optional array of keys to check the validity against.
30
32
 
31
33
  TelephoneNumber.valid?("(555) 555-5555", "US", [:mobile, :fixed_line]) ==> false
32
34
 
33
35
  **To parse a phone number:**
34
36
 
35
- TelephoneNumber.parse("(317) 508-3348", "US") ==>
36
-
37
- #<TelephoneNumber::Number:0x007fe3bc146cf0
38
- @country="US",
37
+ TelephoneNumber.parse("(317) 508-3348", "US") ==>
38
+
39
+ #<TelephoneNumber::Number:0x007fe3bc146cf0
40
+ @country="US",
39
41
  @e164_number="13175083348",
40
42
  @national_number="3175083348",
41
43
  @original_number="3175083348">
42
-
44
+
43
45
  **To fetch valid types:**
44
46
 
45
47
  TelephoneNumber.parse("(317) 508-3348", "US").valid_types ==> ["mobile", "fixed_line"]
46
-
48
+
49
+ **To format nationally:**
50
+
51
+ TelephoneNumber.parse("(317) 508-3348", "US").national_number ==> "(317) 508-3348"
52
+ TelephoneNumber.parse("(317) 508-3348", "US").national_number(formatted: false) ==> "3175083348"
53
+
47
54
  ## Configuration
48
55
 
49
- In the event that you need to override the data that Google is providing, you can do so by setting an override file. This file is expected to be in the same format as Google's as well as serialized using Marshal.
56
+ In the event that you need to override the data that Google is providing, you can do so by setting an override file. This file is expected to be in the same format as Google's as well as serialized using Marshal.
50
57
 
51
- To generate a serialized override file:
58
+ To generate a serialized override file:
52
59
 
53
60
  TelephoneNumber.generate_override_file("/path/to/file")
54
-
61
+
55
62
  In this instance, `/path/to/file` represents an xml file that has your custom data in the same structure that Google's data is in.
56
63
 
57
64
  You can set the override file with:
58
-
65
+
59
66
  TelephoneNumber.override_file = "/path/to_file.dat"
60
-
67
+
61
68
  ## Todo
62
69
 
63
70
  - Build custom validator to integrate with Rails
@@ -68,7 +75,9 @@ You can set the override file with:
68
75
 
69
76
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
70
77
 
71
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
78
+ While developing new functionality, you may want to test against specific phone numbers. In order to do this, add the number to `lib/telephone_number/test_data_generator.rb` and then run `rake data:test:import`. This command will reach out to the demo application provided by Google and pull the correct formats to test against.
79
+
80
+ To install this gem onto your local machine, run `bundle exec rake install`.
72
81
 
73
82
  ## Contributing
74
83
 
data/Rakefile CHANGED
@@ -16,4 +16,10 @@ namespace :data do
16
16
  TelephoneNumber::DataImporter.new(File.expand_path("data/telephone_number_data_file.xml")).import!
17
17
  end
18
18
  end
19
+
20
+ namespace :test do
21
+ task :import do
22
+ TelephoneNumber::TestDataGenerator.import!
23
+ end
24
+ end
19
25
  end
Binary file
@@ -870,11 +870,8 @@
870
870
  mobileNumberPortableRegion="true">
871
871
  <references>
872
872
  <sourceUrl>http://www.itu.int/oth/T0202000009/en</sourceUrl>
873
- <!-- On the following link, click on Indicativos Interurbanos to access detailed
874
- information. -->
875
- <sourceUrl>http://www.cnc.gov.ar/infotecnica/numeracion/Index.asp</sourceUrl>
876
- <!-- Download XLS spreadsheet from "Númeración Geográfica" link on following page: -->
877
- <sourceUrl>http://www.cnc.gob.ar/asignaciones-a-la-fecha_p445</sourceUrl>
873
+ <sourceUrl>https://www.enacom.gob.ar/indicativos-de-servicio_p141</sourceUrl>
874
+ <sourceUrl>https://www.enacom.gob.ar/indicativos-interurbanos_p143</sourceUrl>
878
875
  <sourceUrl>http://en.wikipedia.org/wiki/+54</sourceUrl>
879
876
  </references>
880
877
  <availableFormats>
@@ -1356,7 +1353,7 @@
1356
1353
  )
1357
1354
  </nationalNumberPattern>
1358
1355
  <possibleNumberPattern>\d{6,11}</possibleNumberPattern>
1359
- <possibleLengths national="11" localOnly="6,7,8"/>
1356
+ <possibleLengths national="10,11" localOnly="6,7,8"/>
1360
1357
  <exampleNumber>91123456789</exampleNumber>
1361
1358
  </mobile>
1362
1359
  <tollFree>
@@ -6575,8 +6572,7 @@
6575
6572
  <exampleNumber>21360003</exampleNumber>
6576
6573
  </fixedLine>
6577
6574
  <mobile>
6578
- <!-- 77[0-2] added from numbers found online and user reports. -->
6579
- <nationalNumberPattern>77[0-26-8]\d{5}</nationalNumberPattern>
6575
+ <nationalNumberPattern>77\d{6}</nationalNumberPattern>
6580
6576
  <possibleLengths national="8"/>
6581
6577
  <exampleNumber>77831001</exampleNumber>
6582
6578
  </mobile>
@@ -8110,37 +8106,49 @@
8110
8106
 
8111
8107
  <!-- United Kingdom -->
8112
8108
  <!-- Note that this excludes Isle of Man, Jersey and Guernsey prefixes for the purposes of
8113
- validation, although the formatting rules are shared. -->
8109
+ validation, although the formatting rules are shared. Also numbers are fine-grained where
8110
+ needed in order to disambiguate between the 4 regions. -->
8114
8111
  <territory id="GB" countryCode="44" internationalPrefix="00"
8115
8112
  nationalPrefix="0" preferredExtnPrefix=" x" nationalPrefixFormattingRule="$NP$FG"
8116
8113
  mainCountryForCode="true" mobileNumberPortableRegion="true">
8117
8114
  <references>
8115
+ <sourceUrl>http://static.ofcom.org.uk/static/numbering/</sourceUrl>
8118
8116
  <sourceUrl>http://stakeholders.ofcom.org.uk/telecoms/numbering/</sourceUrl>
8119
8117
  <sourceUrl>http://en.wikipedia.org/wiki/List_of_United_Kingdom_dialling_codes</sourceUrl>
8120
8118
  <sourceUrl>http://www.numberingplans.com/?page=dialling&amp;sub=areacodes&amp;ac=GB</sourceUrl>
8121
8119
  </references>
8122
8120
  <availableFormats>
8123
- <!-- 2d, 55, 56, 70 and 76 pager numbers (excludes 7624) with 10 digits. -->
8124
- <numberFormat pattern="(\d{2})(\d{4})(\d{4})">
8121
+ <!-- 7ddd (not 70, 76) with 10 digits. Includes 76242 for IM. -->
8122
+ <numberFormat pattern="(7\d{3})(\d{6})">
8125
8123
  <leadingDigits>
8126
- 2|
8127
- 5[56]|
8128
8124
  7(?:
8129
- 0|
8130
- 6[013-9]
8125
+ [1-5789]|
8126
+ 62
8131
8127
  )
8132
8128
  </leadingDigits>
8133
8129
  <leadingDigits>
8134
- 2|
8135
- 5[56]|
8136
8130
  7(?:
8137
- 0|
8138
- 6(?:
8139
- [013-9]|
8140
- 2[0-35-9]
8141
- )
8131
+ [1-5789]|
8132
+ 624
8133
+ )
8134
+ </leadingDigits>
8135
+ <leadingDigits>
8136
+ 7(?:
8137
+ [1-5789]|
8138
+ 6242
8142
8139
  )
8143
8140
  </leadingDigits>
8141
+ <format>$1 $2</format>
8142
+ </numberFormat>
8143
+ <!-- 2d, 55, 56, 70 and 76 pager numbers (excludes 76242) with 10 digits. We aren't
8144
+ fine-grained about 76 in the leading digits here for easier maintenance, and this works
8145
+ because the above format applies to 76242 due to ordering. -->
8146
+ <numberFormat pattern="(\d{2})(\d{4})(\d{4})">
8147
+ <leadingDigits>
8148
+ 2|
8149
+ 5[56]|
8150
+ 7[06]
8151
+ </leadingDigits>
8144
8152
  <format>$1 $2 $3</format>
8145
8153
  </numberFormat>
8146
8154
  <!-- 11d, 1d1, 3dd, 9dd with 10 digits. -->
@@ -8201,22 +8209,6 @@
8201
8209
  <leadingDigits>1</leadingDigits>
8202
8210
  <format>$1 $2</format>
8203
8211
  </numberFormat>
8204
- <!-- 7ddd (not 70, 76) with 10 digits. Note: DOES include 7624 when used for IM. -->
8205
- <numberFormat pattern="(7\d{3})(\d{6})">
8206
- <leadingDigits>
8207
- 7(?:
8208
- [1-5789]|
8209
- 62
8210
- )
8211
- </leadingDigits>
8212
- <leadingDigits>
8213
- 7(?:
8214
- [1-5789]|
8215
- 624
8216
- )
8217
- </leadingDigits>
8218
- <format>$1 $2</format>
8219
- </numberFormat>
8220
8212
  <!-- 800 1111 : UK ChildLine. -->
8221
8213
  <numberFormat pattern="(800)(\d{4})">
8222
8214
  <leadingDigits>800</leadingDigits>
@@ -8582,29 +8574,41 @@
8582
8574
  7100-7599, 7700-7999 with 10 digits; excluding ranges used in GG, IM, JE. -->
8583
8575
  <nationalNumberPattern>
8584
8576
  7(?:
8585
- [1-4]\d\d|
8577
+ [1-3]\d{3}|
8578
+ 4(?:
8579
+ [0-46-9]\d{2}|
8580
+ 5(?:
8581
+ [0-689]\d|
8582
+ 7[0-57-9]
8583
+ )
8584
+ )|
8586
8585
  5(?:
8587
8586
  0[0-8]|
8588
8587
  [13-9]\d|
8589
8588
  2[0-35-9]
8590
- )|
8589
+ )\d|
8591
8590
  7(?:
8592
- 0[1-9]|
8593
- [1-7]\d|
8594
- 8[02-9]|
8595
- 9[0-689]
8591
+ 0(?:
8592
+ 0[01]|
8593
+ [1-9]\d
8594
+ )|
8595
+ [1-7]\d{2}|
8596
+ 8[02-9]\d|
8597
+ 9[0-689]\d
8596
8598
  )|
8597
8599
  8(?:
8598
8600
  [014-9]\d|
8599
8601
  [23][0-8]
8600
- )|
8602
+ )\d|
8601
8603
  9(?:
8602
- [04-9]\d|
8603
- 1[02-9]|
8604
- 2[0-35-9]|
8605
- 3[0-689]
8604
+ [024-9]\d{2}|
8605
+ 1(?:
8606
+ [02-9]\d|
8607
+ 1[028]
8608
+ )|
8609
+ 3[0-689]\d
8606
8610
  )
8607
- )\d{6}
8611
+ )\d{5}
8608
8612
  </nationalNumberPattern>
8609
8613
  <possibleNumberPattern>\d{10}</possibleNumberPattern>
8610
8614
  <possibleLengths national="10"/>
@@ -8614,15 +8618,18 @@
8614
8618
  <!-- 76 with 10 digits; excluding ranges used in IM. -->
8615
8619
  <nationalNumberPattern>
8616
8620
  76(?:
8617
- 0[012]|
8618
- 2[356]|
8619
- 4[0134]|
8620
- 5[49]|
8621
- 6[0-369]|
8622
- 77|
8623
- 81|
8624
- 9[39]
8625
- )\d{6}
8621
+ 0[012]\d|
8622
+ 2(?:
8623
+ [356]\d|
8624
+ 4[013-9]
8625
+ )|
8626
+ 4[0134]\d|
8627
+ 5[49]\d|
8628
+ 6[0-369]\d|
8629
+ 77\d|
8630
+ 81\d|
8631
+ 9[39]\d
8632
+ )\d{5}
8626
8633
  </nationalNumberPattern>
8627
8634
  <possibleNumberPattern>\d{10}</possibleNumberPattern>
8628
8635
  <possibleLengths national="10"/>
@@ -8953,10 +8960,13 @@
8953
8960
  </territory>
8954
8961
 
8955
8962
  <!-- Guernsey -->
8956
- <!-- Inherits formatting rules from the UK. -->
8963
+ <!-- Inherits formatting rules from the UK. Note that the numbers are fine-grained where
8964
+ needed in order to disambiguate between the 4 regions i.e UK, Isle of Man, Jersey
8965
+ and Guernsey. -->
8957
8966
  <territory id="GG" countryCode="44" internationalPrefix="00"
8958
8967
  nationalPrefix="0" preferredExtnPrefix=" x" nationalPrefixFormattingRule="$NP$FG">
8959
8968
  <references>
8969
+ <sourceUrl>http://static.ofcom.org.uk/static/numbering/</sourceUrl>
8960
8970
  <sourceUrl>http://en.wikipedia.org/wiki/Telephone_numbers_in_the_United_Kingdom</sourceUrl>
8961
8971
  </references>
8962
8972
  <generalDesc>
@@ -8977,13 +8987,12 @@
8977
8987
  <exampleNumber>1481456789</exampleNumber>
8978
8988
  </fixedLine>
8979
8989
  <mobile>
8980
- <!-- 7781, 7839, 7911 with 10 digits. -->
8981
8990
  <nationalNumberPattern>
8982
8991
  7(?:
8983
- 781|
8984
- 839|
8985
- 911
8986
- )\d{6}
8992
+ 781\d|
8993
+ 839\d|
8994
+ 911[17]
8995
+ )\d{5}
8987
8996
  </nationalNumberPattern>
8988
8997
  <possibleNumberPattern>\d{10}</possibleNumberPattern>
8989
8998
  <possibleLengths national="10"/>
@@ -9150,8 +9159,7 @@
9150
9159
  (?:
9151
9160
  2[034678]\d|
9152
9161
  5(?:
9153
- [047]\d|
9154
- 5[3-6]|
9162
+ [0457]\d|
9155
9163
  6[01]
9156
9164
  )
9157
9165
  )\d{6}
@@ -10426,7 +10434,11 @@
10426
10434
  </leadingDigits>
10427
10435
  <format>$1 $2</format>
10428
10436
  </numberFormat>
10429
- <numberFormat pattern="(8\d{2})(\d{3,4})(\d{3,5})">
10437
+ <numberFormat pattern="(8\d{2})(\d{3,4})(\d{3})">
10438
+ <leadingDigits>8[1-35-9]</leadingDigits>
10439
+ <format>$1-$2-$3</format>
10440
+ </numberFormat>
10441
+ <numberFormat pattern="(8\d{2})(\d{4})(\d{4,5})">
10430
10442
  <leadingDigits>8[1-35-9]</leadingDigits>
10431
10443
  <format>$1-$2-$3</format>
10432
10444
  </numberFormat>
@@ -11039,10 +11051,13 @@
11039
11051
  </territory>
11040
11052
 
11041
11053
  <!-- Isle of Man -->
11042
- <!-- Inherits formatting rules from the UK. -->
11054
+ <!-- Inherits formatting rules from the UK. Note that the numbers are fine-grained where
11055
+ needed in order to disambiguate between the 4 regions i.e UK, Isle of Man, Jersey
11056
+ and Guernsey. -->
11043
11057
  <territory id="IM" countryCode="44" internationalPrefix="00"
11044
11058
  nationalPrefix="0" preferredExtnPrefix=" x" nationalPrefixFormattingRule="$NP$FG">
11045
11059
  <references>
11060
+ <sourceUrl>http://static.ofcom.org.uk/static/numbering/</sourceUrl>
11046
11061
  <sourceUrl>http://en.wikipedia.org/wiki/Telephone_numbers_in_the_United_Kingdom</sourceUrl>
11047
11062
  </references>
11048
11063
  <generalDesc>
@@ -11063,12 +11078,22 @@
11063
11078
  <exampleNumber>1624456789</exampleNumber>
11064
11079
  </fixedLine>
11065
11080
  <mobile>
11066
- <!-- 7524, 7624, 7924 with 10 digits. -->
11067
- <nationalNumberPattern>7[569]24\d{6}</nationalNumberPattern>
11081
+ <nationalNumberPattern>
11082
+ 7(?:
11083
+ 4576|
11084
+ [59]24\d
11085
+ )\d{5}
11086
+ </nationalNumberPattern>
11068
11087
  <possibleNumberPattern>\d{10}</possibleNumberPattern>
11069
11088
  <possibleLengths national="10"/>
11070
11089
  <exampleNumber>7924123456</exampleNumber>
11071
11090
  </mobile>
11091
+ <pager>
11092
+ <nationalNumberPattern>76242\d{5}</nationalNumberPattern>
11093
+ <possibleNumberPattern>\d{10}</possibleNumberPattern>
11094
+ <possibleLengths national="10"/>
11095
+ <exampleNumber>7624212345</exampleNumber>
11096
+ </pager>
11072
11097
  <tollFree>
11073
11098
  <!-- 808 162 with 10 digits. -->
11074
11099
  <nationalNumberPattern>808162\d{4}</nationalNumberPattern>
@@ -11140,23 +11165,17 @@
11140
11165
  </territory>
11141
11166
 
11142
11167
  <!-- India -->
11143
- <!-- Note that several changes in area codes have occurred since the numbering plan was released
11144
- - fixed line changes are notified on the http://www.bsnl.co.in website. Area codes can be
11145
- verified here at http://dq.ndc.bsnl.co.in/bsnl-web/stdSearch.seam. -->
11146
11168
  <territory id="IN" countryCode="91" internationalPrefix="00" nationalPrefix="0"
11147
11169
  leadingZeroPossible="true" nationalPrefixFormattingRule="$NP$FG"
11148
11170
  nationalPrefixOptionalWhenFormatting="true" mobileNumberPortableRegion="true">
11149
11171
  <references>
11150
11172
  <sourceUrl>http://www.itu.int/oth/T0202000063/en</sourceUrl>
11151
11173
  <sourceUrl>http://en.wikipedia.org/wiki/%2B91</sourceUrl>
11152
- <sourceUrl>http://www.coai.in/msccodes.php</sourceUrl>
11153
- <sourceUrl>http://www.dot.gov.in/access-services/allotment-msc-codes</sourceUrl>
11174
+ <sourceUrl>http://www.bsnl.co.in</sourceUrl>
11175
+ <sourceUrl>http://dq.ndc.bsnl.co.in/bsnl-web/stdSearch.seam</sourceUrl>
11154
11176
  </references>
11155
11177
  <availableFormats>
11156
- <!-- This format is for mobile numbers. Note: 8912 is mentioned as Airtel's mobile number
11157
- range in their IR.21 doc but these are landline numbers as per online results. As it
11158
- is not clear we support 8912 as FIXED_LINE_OR_MOBILE and format these numbers in
11159
- fixed-line way. -->
11178
+ <!-- Mobile numbers. We also use this pattern for FIXED_LINE_OR_MOBILE numbers. -->
11160
11179
  <numberFormat pattern="(\d{5})(\d{5})">
11161
11180
  <leadingDigits>
11162
11181
  7(?:
@@ -11230,7 +11249,7 @@
11230
11249
  1[7-9]|
11231
11250
  2[089]|
11232
11251
  4[1-9]|
11233
- 60
11252
+ 6[07]
11234
11253
  )|
11235
11254
  [45]|
11236
11255
  6(?:
@@ -11250,14 +11269,13 @@
11250
11269
  )|
11251
11270
  9(?:
11252
11271
  [035-9]|
11253
- 19|
11272
+ 1[29]|
11254
11273
  2[2-9]|
11255
11274
  4[0-8]
11256
11275
  )
11257
11276
  )|
11258
11277
  9
11259
11278
  </leadingDigits>
11260
- <!-- For 5 digit prefix mobile numbers. -->
11261
11279
  <leadingDigits>
11262
11280
  7(?:
11263
11281
  0|
@@ -11419,7 +11437,10 @@
11419
11437
  8[0-6]
11420
11438
  )|
11421
11439
  4[1-9]|
11422
- 60
11440
+ 6(?:
11441
+ 0|
11442
+ 7[02-7]
11443
+ )
11423
11444
  )|
11424
11445
  [45]|
11425
11446
  6(?:
@@ -11443,7 +11464,7 @@
11443
11464
  )|
11444
11465
  9(?:
11445
11466
  [035-9]|
11446
- 19|
11467
+ 1[29]|
11447
11468
  2[2-9]|
11448
11469
  4[0-8]
11449
11470
  )
@@ -11452,7 +11473,7 @@
11452
11473
  </leadingDigits>
11453
11474
  <format>$1 $2</format>
11454
11475
  </numberFormat>
11455
- <!-- 2 digits area code -->
11476
+ <!-- 2-digit area codes. -->
11456
11477
  <numberFormat pattern="(\d{2})(\d{4})(\d{4})">
11457
11478
  <leadingDigits>
11458
11479
  11|
@@ -11464,7 +11485,7 @@
11464
11485
  </leadingDigits>
11465
11486
  <format>$1 $2 $3</format>
11466
11487
  </numberFormat>
11467
- <!-- 3 digit area codes that don't clash with mobile patterns. -->
11488
+ <!-- 3-digit area codes. -->
11468
11489
  <numberFormat pattern="(\d{3})(\d{3})(\d{4})">
11469
11490
  <leadingDigits>
11470
11491
  1(?:
@@ -11520,13 +11541,7 @@
11520
11541
  6[13]|
11521
11542
  7[14]|
11522
11543
  80
11523
- )
11524
- </leadingDigits>
11525
- <format>$1 $2 $3</format>
11526
- </numberFormat>
11527
- <!-- Three-digit area codes that potentially overlap with mobile. -->
11528
- <numberFormat pattern="(\d{3})(\d{3})(\d{4})">
11529
- <leadingDigits>
11544
+ )|
11530
11545
  7(?:
11531
11546
  12|
11532
11547
  2[14]|
@@ -11535,26 +11550,7 @@
11535
11550
  5[15]|
11536
11551
  [67]1|
11537
11552
  88
11538
- )
11539
- </leadingDigits>
11540
- <leadingDigits>
11541
- 7(?:
11542
- 12|
11543
- 2[14]|
11544
- 3[134]|
11545
- 4[47]|
11546
- 5(?:
11547
- 1|
11548
- 5[2-6]
11549
- )|
11550
- [67]1|
11551
- 88
11552
- )
11553
- </leadingDigits>
11554
- <format>$1 $2 $3</format>
11555
- </numberFormat>
11556
- <numberFormat pattern="(\d{3})(\d{3})(\d{4})">
11557
- <leadingDigits>
11553
+ )|
11558
11554
  8(?:
11559
11555
  16|
11560
11556
  2[014]|
@@ -11567,8 +11563,7 @@
11567
11563
  </leadingDigits>
11568
11564
  <format>$1 $2 $3</format>
11569
11565
  </numberFormat>
11570
- <!-- 4 digits area code -->
11571
- <!-- Fallback for fixed-line numbers. -->
11566
+ <!-- 4-digit area codes. -->
11572
11567
  <numberFormat pattern="(\d{4})(\d{3})(\d{3})">
11573
11568
  <leadingDigits>
11574
11569
  1(?:
@@ -11583,40 +11578,34 @@
11583
11578
  <leadingDigits>008</leadingDigits>
11584
11579
  <format>$1 $2 $3 $4</format>
11585
11580
  </numberFormat>
11586
- <numberFormat nationalPrefixFormattingRule="$FG"
11587
- pattern="(1600)(\d{2})(\d{4})">
11581
+ <numberFormat nationalPrefixFormattingRule="$FG" pattern="(\d{3})(\d{3})(\d{4})">
11582
+ <leadingDigits>140</leadingDigits>
11583
+ <format>$1 $2 $3</format>
11584
+ </numberFormat>
11585
+ <numberFormat nationalPrefixFormattingRule="$FG" pattern="(\d{4})(\d{2})(\d{4})">
11588
11586
  <leadingDigits>160</leadingDigits>
11589
11587
  <leadingDigits>1600</leadingDigits>
11590
11588
  <format>$1 $2 $3</format>
11591
11589
  </numberFormat>
11592
- <numberFormat nationalPrefixFormattingRule="$FG"
11593
- pattern="(1800)(\d{4,5})">
11590
+ <numberFormat nationalPrefixFormattingRule="$FG" pattern="(\d{4})(\d{4,5})">
11594
11591
  <leadingDigits>180</leadingDigits>
11595
11592
  <leadingDigits>1800</leadingDigits>
11596
11593
  <format>$1 $2</format>
11597
11594
  </numberFormat>
11598
- <numberFormat nationalPrefixFormattingRule="$FG"
11599
- pattern="(18[06]0)(\d{2,4})(\d{4})">
11600
- <leadingDigits>18[06]</leadingDigits>
11601
- <leadingDigits>18[06]0</leadingDigits>
11595
+ <numberFormat nationalPrefixFormattingRule="$FG" pattern="(\d{4})(\d{2,4})(\d{4})">
11596
+ <leadingDigits>180</leadingDigits>
11597
+ <leadingDigits>1800</leadingDigits>
11602
11598
  <format>$1 $2 $3</format>
11603
11599
  </numberFormat>
11604
- <numberFormat nationalPrefixFormattingRule="$FG"
11605
- pattern="(140)(\d{3})(\d{4})">
11606
- <leadingDigits>140</leadingDigits>
11600
+ <numberFormat nationalPrefixFormattingRule="$FG" pattern="(\d{4})(\d{3,4})(\d{4})">
11601
+ <leadingDigits>186</leadingDigits>
11602
+ <leadingDigits>1860</leadingDigits>
11607
11603
  <format>$1 $2 $3</format>
11608
11604
  </numberFormat>
11609
- <!-- Televoting numbers. Formatting information is from
11605
+ <!-- Formatting information for the televoting numbers is from
11610
11606
  http://www.bsnl.co.in/service/telev.htm -->
11611
- <numberFormat nationalPrefixFormattingRule="$FG"
11612
- pattern="(\d{4})(\d{3})(\d{3})(\d{3})">
11607
+ <numberFormat nationalPrefixFormattingRule="$FG" pattern="(\d{4})(\d{3})(\d{3})(\d{3})">
11613
11608
  <leadingDigits>18[06]</leadingDigits>
11614
- <leadingDigits>
11615
- 18(?:
11616
- 0[03]|
11617
- 6[12]
11618
- )
11619
- </leadingDigits>
11620
11609
  <format>$1 $2 $3 $4</format>
11621
11610
  </numberFormat>
11622
11611
  </availableFormats>
@@ -11844,7 +11833,7 @@
11844
11833
  numbers. It seems almost impossible to know for some of these numbers whether they are
11845
11834
  land-line or mobile, since the ranges overlap. We go to a maximum depth of five where
11846
11835
  necessary to distinguish between mobile and fixed-line numbers. Extra prefixes added:
11847
- 72878, 74209, 74599, 7601, 768[56], 7695, 8309, 83293, 863[89]0 and 8639[29]. New
11836
+ 72878, 74209, 74599, 7601, 768[56], 7695, 8309, 8329[34], 863[89]0 and 8639[29]. New
11848
11837
  prefixes were also added based on the document provided from mobile carriers:
11849
11838
  https://github.com/googlei18n/libphonenumber/issues/260 and
11850
11839
  https://github.com/googlei18n/libphonenumber/pull/692/ -->
@@ -12026,10 +12015,13 @@
12026
12015
  2(?:
12027
12016
  0\d|
12028
12017
  8[0-6]|
12029
- 93
12018
+ 9[34]
12030
12019
  )|
12031
12020
  4[1-9]\d|
12032
- 60\d
12021
+ 6(?:
12022
+ 0\d|
12023
+ 7[02-7]
12024
+ )
12033
12025
  )|
12034
12026
  [45]\d{3}|
12035
12027
  6(?:
@@ -12729,10 +12721,13 @@
12729
12721
  </territory>
12730
12722
 
12731
12723
  <!-- Jersey -->
12732
- <!-- Inherits formatting rules from the UK. -->
12724
+ <!-- Inherits formatting rules from the UK. Note that the numbers are fine-grained where
12725
+ needed in order to disambiguate between the 4 regions i.e UK, Isle of Man, Jersey
12726
+ and Guernsey. -->
12733
12727
  <territory id="JE" countryCode="44" internationalPrefix="00"
12734
12728
  nationalPrefix="0" preferredExtnPrefix=" x" nationalPrefixFormattingRule="$NP$FG">
12735
12729
  <references>
12730
+ <sourceUrl>http://static.ofcom.org.uk/static/numbering/</sourceUrl>
12736
12731
  <sourceUrl>http://en.wikipedia.org/wiki/Telephone_numbers_in_the_United_Kingdom</sourceUrl>
12737
12732
  <sourceUrl>http://www.jcra.je/cms3/v2/public/cmsChild.asp?pageID=1024&amp;childID=1036</sourceUrl>
12738
12733
  </references>
@@ -12754,21 +12749,20 @@
12754
12749
  <exampleNumber>1534456789</exampleNumber>
12755
12750
  </fixedLine>
12756
12751
  <mobile>
12757
- <!-- 7509, 7700, 7797, 7829, 7937 with 10 digits. -->
12758
12752
  <nationalNumberPattern>
12759
12753
  7(?:
12760
- 509|
12754
+ 509\d|
12761
12755
  7(?:
12762
- 00|
12763
- 97
12756
+ 00[378]|
12757
+ 97[7-9]
12764
12758
  )|
12765
- 829|
12766
- 937
12767
- )\d{6}
12759
+ 829\d|
12760
+ 937\d
12761
+ )\d{5}
12768
12762
  </nationalNumberPattern>
12769
12763
  <possibleNumberPattern>\d{10}</possibleNumberPattern>
12770
12764
  <possibleLengths national="10"/>
12771
- <exampleNumber>7797123456</exampleNumber>
12765
+ <exampleNumber>7797712345</exampleNumber>
12772
12766
  </mobile>
12773
12767
  <pager>
12774
12768
  <!-- Pager numbers as per GB. -->
@@ -16333,11 +16327,11 @@
16333
16327
  5(?:
16334
16328
  2(?:
16335
16329
  [2-48]|
16336
- 90
16330
+ 9[0-7]
16337
16331
  )|
16338
16332
  3(?:
16339
16333
  [5-79]|
16340
- 80
16334
+ 8[0-7]
16341
16335
  )|
16342
16336
  924
16343
16337
  )|
@@ -16390,34 +16384,20 @@
16390
16384
  <nationalNumberPattern>
16391
16385
  5(?:
16392
16386
  2(?:
16393
- (?:
16394
- [015-7]\d|
16395
- 2[02-9]|
16396
- 3[2-57]|
16397
- 4[2-8]|
16398
- 8[235-7]
16399
- )\d|
16400
- 9(?:
16401
- 0\d|
16402
- [89]0
16403
- )
16404
- )|
16387
+ [015-79]\d|
16388
+ 2[02-9]|
16389
+ 3[2-57]|
16390
+ 4[2-8]|
16391
+ 8[235-7]
16392
+ )\d|
16405
16393
  3(?:
16406
- (?:
16407
- [0-4]\d|
16408
- [57][2-9]|
16409
- 6[2-8]|
16410
- 9[3-9]
16411
- )\d|
16412
- 8(?:
16413
- 0\d|
16414
- [89]0
16415
- )
16416
- )|
16417
- (?:
16418
- 4[067]|
16419
- 5[03]
16420
- )\d{2}
16394
+ [0-48]\d|
16395
+ [57][2-9]|
16396
+ 6[2-8]|
16397
+ 9[3-9]
16398
+ )\d|
16399
+ 4[067]\d{2}|
16400
+ 5[03]\d{2}
16421
16401
  )\d{4}
16422
16402
  </nationalNumberPattern>
16423
16403
  <possibleLengths national="9"/>
@@ -17581,11 +17561,11 @@
17581
17561
  <exampleNumber>596301234</exampleNumber>
17582
17562
  </fixedLine>
17583
17563
  <mobile>
17584
- <!-- The prefix 69653 is a valid number which was found online in few websites. -->
17564
+ <!-- 6965[2-4] were found in use online. -->
17585
17565
  <nationalNumberPattern>
17586
17566
  696(?:
17587
17567
  [0-479]\d|
17588
- 5[013]|
17568
+ 5[0-4]|
17589
17569
  8[0-689]
17590
17570
  )\d{4}
17591
17571
  </nationalNumberPattern>
@@ -18434,7 +18414,7 @@
18434
18414
  <exampleNumber>21123456</exampleNumber>
18435
18415
  </fixedLine>
18436
18416
  <mobile>
18437
- <nationalNumberPattern>8[23467]\d{7}</nationalNumberPattern>
18417
+ <nationalNumberPattern>8[2-7]\d{7}</nationalNumberPattern>
18438
18418
  <possibleNumberPattern>\d{9}</possibleNumberPattern>
18439
18419
  <possibleLengths national="9"/>
18440
18420
  <exampleNumber>821234567</exampleNumber>
@@ -21240,14 +21220,15 @@
21240
21220
  <references>
21241
21221
  <sourceUrl>http://www.itu.int/oth/T02020000AC/en</sourceUrl>
21242
21222
  <sourceUrl>http://en.wikipedia.org/wiki/Telephone_numbers_in_Romania</sourceUrl>
21223
+ <sourceUrl>http://www.ancom.org.ro/en/presentation-of-romanian-national-numbering-plan-according-to-itu-t-recommendation-e129-_5523</sourceUrl>
21243
21224
  </references>
21244
21225
  <availableFormats>
21245
21226
  <numberFormat pattern="(\d{2})(\d{3})(\d{4})">
21246
21227
  <leadingDigits>[23]1</leadingDigits>
21247
21228
  <format>$1 $2 $3</format>
21248
21229
  </numberFormat>
21249
- <numberFormat pattern="(21)(\d{4})">
21250
- <leadingDigits>21</leadingDigits>
21230
+ <numberFormat pattern="(\d{2})(\d{4})">
21231
+ <leadingDigits>[23]1</leadingDigits>
21251
21232
  <format>$1 $2</format>
21252
21233
  </numberFormat>
21253
21234
  <numberFormat pattern="(\d{3})(\d{3})(\d{3})">
@@ -21267,8 +21248,8 @@
21267
21248
  </availableFormats>
21268
21249
  <generalDesc>
21269
21250
  <nationalNumberPattern>
21270
- 2\d{5,8}|
21271
- [37-9]\d{8}
21251
+ [23]\d{5,8}|
21252
+ [7-9]\d{8}
21272
21253
  </nationalNumberPattern>
21273
21254
  <!-- Although the ITU plan says the number plan is open, this was changed in 2008 according
21274
21255
  to wikipedia and people must dial the full number. However, there are still short
@@ -21292,7 +21273,10 @@
21292
21273
  \d9\d{2}
21293
21274
  )
21294
21275
  )|
21295
- 3[13-6]\d{7}
21276
+ 3(?:
21277
+ 1\d{4}(?:\d{3})?|
21278
+ [3-6]\d{7}
21279
+ )
21296
21280
  </nationalNumberPattern>
21297
21281
  <possibleLengths national="6,9"/>
21298
21282
  <exampleNumber>211234567</exampleNumber>
@@ -26366,12 +26350,23 @@
26366
26350
  <references>
26367
26351
  <sourceUrl>http://www.itu.int/oth/T02020000C1/en</sourceUrl>
26368
26352
  <sourceUrl>http://en.wikipedia.org/wiki/Telephone_numbers_in_South_Africa</sourceUrl>
26353
+ <sourceUrl>
26354
+ https://www.icasa.org.za/Portals/0/Regulations/Regulations/NumberingPlanReg.pdf
26355
+ </sourceUrl>
26369
26356
  </references>
26370
26357
  <availableFormats>
26371
26358
  <numberFormat pattern="(860)(\d{3})(\d{3})">
26372
26359
  <leadingDigits>860</leadingDigits>
26373
26360
  <format>$1 $2 $3</format>
26374
26361
  </numberFormat>
26362
+ <numberFormat pattern="(\d{2})(\d{3,4})">
26363
+ <leadingDigits>8[1-4]</leadingDigits>
26364
+ <format>$1 $2</format>
26365
+ </numberFormat>
26366
+ <numberFormat pattern="(\d{2})(\d{3})(\d{2,3})">
26367
+ <leadingDigits>8[1-4]</leadingDigits>
26368
+ <format>$1 $2 $3</format>
26369
+ </numberFormat>
26375
26370
  <numberFormat pattern="(\d{2})(\d{3})(\d{4})">
26376
26371
  <leadingDigits>
26377
26372
  [1-79]|
@@ -26382,32 +26377,19 @@
26382
26377
  </leadingDigits>
26383
26378
  <format>$1 $2 $3</format>
26384
26379
  </numberFormat>
26385
- <numberFormat pattern="(\d{2})(\d{3,4})">
26386
- <leadingDigits>8[1-4]</leadingDigits>
26387
- <format>$1 $2</format>
26388
- </numberFormat>
26389
- <numberFormat pattern="(\d{2})(\d{3})(\d{2,3})">
26390
- <leadingDigits>8[1-4]</leadingDigits>
26391
- <format>$1 $2 $3</format>
26392
- </numberFormat>
26393
26380
  </availableFormats>
26394
26381
  <generalDesc>
26395
26382
  <nationalNumberPattern>
26396
26383
  [1-79]\d{8}|
26397
- 8(?:
26398
- [05-7]\d{7}|
26399
- [1-4]\d{3,7}
26400
- )
26384
+ 8\d{4,8}
26401
26385
  </nationalNumberPattern>
26402
26386
  <possibleNumberPattern>\d{5,9}</possibleNumberPattern>
26403
26387
  </generalDesc>
26404
26388
  <fixedLine>
26405
- <!-- Wikipedia is missing 020, and the 024 code it lists for Somerset West stopped being
26406
- used in 1996. -->
26407
26389
  <nationalNumberPattern>
26408
26390
  (?:
26409
26391
  1[0-8]|
26410
- 2[0-378]|
26392
+ 2[1-378]|
26411
26393
  3[1-69]|
26412
26394
  4\d|
26413
26395
  5[1346-8]
@@ -26425,7 +26407,7 @@
26425
26407
  national prefix). -->
26426
26408
  <nationalNumberPattern>
26427
26409
  (?:
26428
- 6[0-5]|
26410
+ 6\d|
26429
26411
  7[0-46-9]
26430
26412
  )\d{7}|
26431
26413
  8(?:
@@ -26445,7 +26427,7 @@
26445
26427
  <premiumRate>
26446
26428
  <nationalNumberPattern>
26447
26429
  86[2-9]\d{6}|
26448
- 90\d{7}
26430
+ 9[0-2]\d{7}
26449
26431
  </nationalNumberPattern>
26450
26432
  <possibleNumberPattern>\d{9}</possibleNumberPattern>
26451
26433
  <possibleLengths national="9"/>
@@ -26457,6 +26439,9 @@
26457
26439
  <possibleLengths national="9"/>
26458
26440
  <exampleNumber>860123456</exampleNumber>
26459
26441
  </sharedCost>
26442
+ <!-- 88 used to be assigned to pagers prior to a migration in 2010, where it was unassigned.
26443
+ According to an official doc from 2016, 88 is "Released" for "Future non-geographic
26444
+ services", but we don't know yet what these are, so we do not validate them. -->
26460
26445
  <voip>
26461
26446
  <nationalNumberPattern>87\d{7}</nationalNumberPattern>
26462
26447
  <possibleNumberPattern>\d{9}</possibleNumberPattern>