Permalink
Browse files

+ Length validations for Germany and Italy

  • Loading branch information...
1 parent e15b972 commit 6e634260cf0ef63f9c5ae98de4af970b0b5e2a53 @jcfischer jcfischer committed with Jan 10, 2013
Showing with 22 additions and 3 deletions.
  1. +3 −1 lib/phony/countries/germany.rb
  2. +2 −1 lib/phony/countries/italy.rb
  3. +17 −1 spec/lib/phony/validations_spec.rb
@@ -4069,5 +4069,7 @@
country '49', one_of(service) >> split(3,10) |
match(/^(1[567]\d)\d*$/) >> split(3,10) | # Mobile
one_of(ndcs) >> split(3,10) |
- fixed(5) >> split(3,10)
+ fixed(5) >> split(3,10),
+ length( 2 => 5..10, 3 => 7..12, 4 => 7..11, 5 => 8..11 )
+
end
@@ -180,5 +180,6 @@
)
Phony.define do
- country '39', Phony::Country.new(*handlers)
+ country '39', Phony::Country.new(*handlers), length( 2 => 6..11, 3 => 9..11, 4 => 6..11 )
+
end
@@ -109,7 +109,23 @@
Phony.plausible?('+234 807 766 1234').should be_true
Phony.plausible?('+234 807 766 123').should be_false
end
-
+ it 'is correct for Italian numbers' do
+ Phony.plausible?('+39 06 123 4567').should be_true
+ Phony.plausible?('+39 335 123 4567').should be_true
+ Phony.plausible?('+39 335 123').should be_false
+ end
+ it 'is correct for German numbers' do
+ Phony.plausible?('+49 40 123 45678').should be_true
+ Phony.plausible?('+49 40 123 456789').should be_false
+ Phony.plausible?('+49 171 123 456789').should be_true
+ Phony.plausible?('+49 171 123').should be_false
+ Phony.plausible?('+49 991 1234').should be_true
+ Phony.plausible?('+49 2041 123').should be_true
+ Phony.plausible?('+49 2041 1234567').should be_true
+ Phony.plausible?('+49 2041 12345689').should be_false
+ Phony.plausible?('+49 31234 123456').should be_true
+ Phony.plausible?('+49 31234 1234567').should be_false
+ end
it "is correct for US numbers" do
# Sorry, still need E164 conform numbers.

0 comments on commit 6e63426

Please sign in to comment.