Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
16 changes: 7 additions & 9 deletions lib/phony/countries/germany.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4076,14 +4076,12 @@

Phony.define do
country '49',
one_of(service) >> split(3,0) |
one_of('176') >> split(3,5) |
one_of('1609') >> split(3,4..5) |
one_of(service) >> split(3,0) |
match(/\A(151[124567]|152[012359]|157[035789]|1590)\d*\z/) >> split(3,4) |
match(/\A(1[57]\d)\d*\z/) >> split(3,4) |
match(/\A(16\d)\d*\z/) >> split(3,4..5) |
one_of(ndcs2) >> split(3,0..6) |
one_of(ndcs3) >> split(3,0..5) |
one_of(ndcs4) >> split(3,0..5) |
fixed(5) >> split(3,3..3)
match(/\A(15\d)\d*\z/) >> split(3,4) |
match(/\A(1[67]\d)\d*\z/) >> split(3,4..5) | # Seite 49
one_of(ndcs2) >> split(3,0..11) | # 5-9 Stellen nach Seite 32, http://www.bundesnetzagentur.de/cln_1911/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Nummerierung/Nummerierungskonzept/nummerierungskonzept_node.html
one_of(ndcs3) >> split(3,0..10) |
one_of(ndcs4) >> split(3,0..9) |
fixed(5) >> split(3,0..8)
end
22 changes: 21 additions & 1 deletion spec/functional/plausibility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def self.it_is_correct_for(country_name, options={})
Phony.plausible?('+49 160 123 1234').should be_true # Mobile Number 7 digits
Phony.plausible?('+49 160 123 12345').should be_true # Mobile Number 8 digits
Phony.plausible?('+49 171 123 4567').should be_true
Phony.plausible?('+49 171 123 45678').should be_false
Phony.plausible?('+49 171 123 45678').should be_true # is a valid number according German authority "bundesnetzagentur": http://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Nummerierung/Rufnummern/ONRufnr/NummernplanOrtsnetzrufnummern.pdf?__blob=publicationFile&v=2 (04.24.2014)
Phony.plausible?('+49 177 123 1234').should be_true
Phony.plausible?('+49 176 123 12345').should be_true
Phony.plausible?('+49 991 1234').should be_true # stricter 3 digit ndc rules
Expand All @@ -304,6 +304,26 @@ def self.it_is_correct_for(country_name, options={})
Phony.plausible?('+49 31234 123456').should be_true
Phony.plausible?('+49 7141 12345670').should be_true
Phony.plausible?('+49 1609 1234567').should be_true # Bug: https://github.com/floere/phony/issues/146
# Following tests implement specifications from
# http://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Nummerierung/Rufnummern/ONRufnr/NummernplanOrtsnetzrufnummern.pdf?__blob=publicationFile&v=2 (04.24.2014)
# Page 3
Phony.plausible?('+49 89 12345678').should be_true # NZ-E
Phony.plausible?('+49 89 123456789').should be_true # NZ-E & NZ-Z
Phony.plausible?('+49 89 1234567890').should be_true # NZ-Z
Phony.plausible?('+49 209 1234567').should be_true # NZ-E
Phony.plausible?('+49 209 12345678').should be_true # NZ-E & NZ-Z
Phony.plausible?('+49 209 123456789').should be_true # NZ-Z
Phony.plausible?('+49 6421 123456').should be_true # NZ-E
Phony.plausible?('+49 6421 1234567').should be_true # NZ-E & NZ-Z
Phony.plausible?('+49 6421 12345678').should be_true # NZ-Z
Phony.plausible?('+49 33053 12345').should be_true # NZ-E
Phony.plausible?('+49 33053 123456').should be_true # NZ-E & NZ-Z
Phony.plausible?('+49 33053 1234567').should be_true # NZ-Z
# Point 2.3c) Numbers can be up to 13 Digits long without prefix according to E.164
Phony.plausible?('+49 33053 12345678').should be_true
Phony.plausible?('+49 6421 123456789').should be_true
Phony.plausible?('+49 209 1234567890').should be_true
Phony.plausible?('+49 40 12345678901').should be_true
end

it 'is correct for Israelian numbers' do
Expand Down

0 comments on commit 3861a6a

Please sign in to comment.