Skip to content

Commit

Permalink
Merge pull request #391 from lukkry/lukkry/update-rules-for-nz-3
Browse files Browse the repository at this point in the history
Update rules for NZ numbers
  • Loading branch information
floere committed Nov 24, 2017
2 parents 46e600f + 7ca55e8 commit 8de8152
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/phony/countries.rb
Expand Up @@ -274,6 +274,8 @@
match(/^(2\d)\d{7}$/) >> split(3,4) | # Mobile
match(/^(2\d)\d{6}$/) >> split(3,3) |
match(/^(2\d)\d{8}$/) >> split(2,3,3) |
match(/^(800)\d{6}$/) >> split(3,3) | # International 800 service where agreed
match(/^(800)\d{7}$/) >> split(3,4) | # International 800 service where agreed
fixed(1) >> split(3,4) # Rest

# Singapore (Republic of).
Expand Down
4 changes: 4 additions & 0 deletions spec/functional/plausibility_spec.rb
Expand Up @@ -218,6 +218,10 @@ def self.it_is_correct_for(country_name, options={})
'+977 10 123 456',
'+977 98 1234 5678']
it_is_correct_for "New Caledonia (Territoire français d'outre-mer)", :samples => '+687 546 835'
it 'is correct for New Zealand' do
Phony.plausible?('+64800123123').should be_true # Free phone
Phony.plausible?('+648001231234').should be_true # Free phone
end
it_is_correct_for 'Nicaragua', :samples => '+505 12 345 678'
it_is_correct_for 'Niger', :samples => '+227 1234 5678'
it_is_correct_for 'Niue', :samples => '+683 3791'
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/phony/countries_spec.rb
Expand Up @@ -794,6 +794,8 @@ def self.it_splits number, expected
end
describe 'New Zealand' do
it_splits '6491234567', ['64', '9', '123', '4567']
it_splits '64800123123', ['64', '800', '123', '123']
it_splits '648001231234', ['64', '800', '123', '1234']
end
describe 'Bhutan (Kingdom of)' do
it_splits '9759723642', %w(975 9 723 642)
Expand Down

0 comments on commit 8de8152

Please sign in to comment.