Skip to content

Commit a5d2db6

Browse files
authored
Merge pull request #567 from davemcginnzendesk/add-nigeria-20-area-code
Add support for Nigerian area code 20
2 parents 905b32f + 9f46efb commit a5d2db6

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/phony/countries.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@
432432
match(/^([7-9]0\d)\d+$/) >> split(3, 4) | # Mobile
433433
match(/^(81\d)\d+$/) >> split(3, 4) | # Mobile
434434
match(/^(91\d)\d+$/) >> split(3, 4) | # Mobile
435+
one_of('20') >> split(3, 3..5) | # 2-digit NDC (area code 20) - must come before 1-digit '2'
435436
one_of('1', '2') >> split(3, 3..4) | # Lagos, Ibadan
436437
one_of('9') >> split(3, 4) | # Abuja
437438
one_of((30..79).map(&:to_s)) >> split(3, 2..3) | # 2-digit NDC

spec/functional/plausibility_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ def self.it_is_correct_for(country_name, options = {})
413413
'+234 811 234 5678',
414414
'+234 64 830 00',
415415
'+234 1 280 444',
416-
'+234 85 123 456']
416+
'+234 85 123 456',
417+
['+234 20 123 456', '+234 20 123 4567']]
417418
it_is_correct_for 'Niue', samples: '+683 3791'
418419
it_is_correct_for 'Oman', samples: ['+968 24 423 123',
419420
'+968 25 423 123']

spec/lib/phony/countries_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,9 @@ def self.it_splits(number, expected)
13001300
describe 'Nigeria' do
13011301
it_splits '23411231234', %w[234 1 123 1234] # Lagos
13021302

1303+
it_splits '23420123456', %w[234 20 123 456] # Area code 20 (7 digits)
1304+
it_splits '234201234567', %w[234 20 123 4567] # Area code 20 (8 digits)
1305+
13031306
it_splits '23445123456', %w[234 45 123 456] # Ogoja
13041307

13051308
# mobile numbers

0 commit comments

Comments
 (0)