Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

+ length validation for Nigerian numbers

  • Loading branch information...
commit 2607f3127cbfb5bf075eb7091fdf6fa78c79da6b 1 parent bd896ad
@jcfischer jcfischer authored committed
Showing with 15 additions and 1 deletion.
  1. +2 −1  lib/phony/countries.rb
  2. +13 −0 spec/lib/phony/validations_spec.rb
View
3  lib/phony/countries.rb
@@ -309,7 +309,8 @@
match(/^(702\d)\d+$/) >> split(3,4) | # Mobile
match(/^(70[3-9])\d+$/) >> split(3,4) | # Mobile
match(/^(8[01]\d)\d+$/) >> split(3,4) | # Mobile
- fixed(2) >> split(3,4) # 2-digit NDC
+ fixed(2) >> split(3,4), # 2-digit NDC
+ length( 1 => 8, 2 => 9, 3 => 10)
country '235', todo # Chad
View
13 spec/lib/phony/validations_spec.rb
@@ -97,6 +97,19 @@
Phony.plausible?('+20 40 1234567').should be_false
end
+ it 'is correct for Dutch numbers' do
+ Phony.plausible?('+31 6 12 34 56 78').should be_true
+ Phony.plausible?('+31 6 12 34 56 7').should be_false
+ Phony.plausible?('+31 20 123 5678').should be_true
+ Phony.plausible?('+31 20 123 567').should be_false
+ Phony.plausible?('+31 221 123 567').should be_true
+ Phony.plausible?('+31 221 123 56').should be_false
+ end
+ it 'is correct for Nigerian numbers' do
+ Phony.plausible?('+234 807 766 1234').should be_true
+ Phony.plausible?('+234 807 766 123').should be_false
+ end
+
it "is correct for US numbers" do
# Sorry, still need E164 conform numbers.
Please sign in to comment.
Something went wrong with that request. Please try again.