phony 1.9.0 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +1 -1
- data/lib/phony.rb +28 -15
- data/lib/phony/countries.rb +609 -210
- data/lib/phony/countries/austria.rb +6 -1
- data/lib/phony/countries/bangladesh.rb +55 -0
- data/lib/phony/countries/belarus.rb +130 -0
- data/lib/phony/countries/georgia.rb +91 -0
- data/lib/phony/countries/germany.rb +20 -6
- data/lib/phony/countries/india.rb +50 -0
- data/lib/phony/countries/indonesia.rb +50 -0
- data/lib/phony/countries/italy.rb +38 -67
- data/lib/phony/countries/japan.rb +412 -0
- data/lib/phony/countries/kyrgyzstan.rb +118 -0
- data/lib/phony/countries/latvia.rb +40 -0
- data/lib/phony/countries/libya.rb +114 -0
- data/lib/phony/countries/malaysia.rb +7 -5
- data/lib/phony/countries/moldova.rb +50 -0
- data/lib/phony/countries/montenegro.rb +27 -0
- data/lib/phony/countries/namibia.rb +35 -0
- data/lib/phony/countries/nepal.rb +71 -0
- data/lib/phony/countries/netherlands.rb +3 -2
- data/lib/phony/countries/pakistan.rb +119 -0
- data/lib/phony/countries/paraguay.rb +145 -0
- data/lib/phony/countries/russia_kazakhstan_abhasia_south_osetia.rb +6 -6
- data/lib/phony/countries/serbia.rb +34 -0
- data/lib/phony/countries/somali.rb +22 -0
- data/lib/phony/countries/south_korea.rb +1 -1
- data/lib/phony/countries/sweden.rb +1 -1
- data/lib/phony/countries/taiwan.rb +51 -0
- data/lib/phony/countries/tajikistan.rb +76 -0
- data/lib/phony/countries/turkmenistan.rb +73 -0
- data/lib/phony/countries/ukraine.rb +614 -0
- data/lib/phony/countries/uruguay.rb +51 -0
- data/lib/phony/countries/zimbabwe.rb +37 -0
- data/lib/phony/country.rb +41 -0
- data/lib/phony/country_codes.rb +45 -18
- data/lib/phony/dsl.rb +33 -7
- data/lib/phony/local_splitters/fixed.rb +14 -1
- data/lib/phony/local_splitters/regex.rb +12 -1
- data/lib/phony/national_code.rb +7 -3
- data/lib/phony/national_splitters/default.rb +13 -1
- data/lib/phony/national_splitters/dsl.rb +9 -7
- data/lib/phony/national_splitters/fixed.rb +6 -0
- data/lib/phony/national_splitters/none.rb +6 -0
- data/lib/phony/national_splitters/regex.rb +6 -0
- data/lib/phony/national_splitters/variable.rb +7 -1
- data/spec/lib/phony/countries_spec.rb +684 -16
- data/spec/lib/phony/local_splitters/regex_spec.rb +41 -0
- data/spec/lib/phony/validations_spec.rb +542 -10
- data/spec/lib/phony_spec.rb +20 -6
- metadata +29 -9
- data/lib/phony/validator.rb +0 -26
- data/lib/phony/validators.rb +0 -88
@@ -45,5 +45,46 @@ describe Phony::LocalSplitters::Regex do
|
|
45
45
|
performance_of { @splitter.split('91234567').should == ['912','34','567'] }.should < 0.00004
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
describe 'plausible?' do
|
50
|
+
let(:number) {['123', '456']}
|
51
|
+
let(:result) { local_splitter.plausible?(number) }
|
52
|
+
|
53
|
+
context 'Local splitter without mappings' do
|
54
|
+
let(:local_splitter) { described_class.instance_for({})}
|
55
|
+
it 'returns false' do
|
56
|
+
result.should be_false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'Mapping does not exist for a number' do
|
61
|
+
let(:local_splitter) { described_class.instance_for /\A5/ => [1,2,3]}
|
62
|
+
it 'returns false' do
|
63
|
+
result.should be_false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "Mapping exists, but the length is greater" do
|
68
|
+
let(:local_splitter) { described_class.instance_for /\A123/ => [2,2]}
|
69
|
+
it 'returns false' do
|
70
|
+
result.should be_false
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "Mapping exists, but the length is less" do
|
75
|
+
let(:local_splitter) { described_class.instance_for /\A123/ => [2,2,3]}
|
76
|
+
it 'returns false' do
|
77
|
+
result.should be_false
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'Mapping exists and the length is equal' do
|
82
|
+
let(:local_splitter) { described_class.instance_for /\A123/ => [2,2,2]}
|
83
|
+
it 'returns true' do
|
84
|
+
result.should be_true
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
48
89
|
|
49
90
|
end
|
@@ -5,6 +5,33 @@ require 'spec_helper'
|
|
5
5
|
describe 'validations' do
|
6
6
|
|
7
7
|
describe 'plausible?' do
|
8
|
+
|
9
|
+
# Validations test helper.
|
10
|
+
# @param country_name [String]
|
11
|
+
# @param options [Hash]
|
12
|
+
# @option options [String, Array<String>] :samples
|
13
|
+
#
|
14
|
+
def self.it_is_correct_for(country_name, options={})
|
15
|
+
samples = [*options[:samples]]
|
16
|
+
raise ArgumentError, ':samples option should be specified' if samples.empty?
|
17
|
+
|
18
|
+
it "is correct for #{country_name}" do
|
19
|
+
samples.each do |sample|
|
20
|
+
correct = [*sample]
|
21
|
+
|
22
|
+
shortest = correct.min_by{|x| x.scan(/\d/).length}
|
23
|
+
longest = correct.max_by{|x| x.scan(/\d/).length}
|
24
|
+
incorrect = [shortest.sub(/\d\s*\z/, ''), longest + '0']
|
25
|
+
|
26
|
+
correct.each do |value|
|
27
|
+
Phony.plausible?(value).should be_true, "not validates '#{value}', but should"
|
28
|
+
end
|
29
|
+
incorrect.each do |value|
|
30
|
+
Phony.plausible?(value).should be_false, "validates '#{value}', but should not"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
8
35
|
|
9
36
|
it 'does not change the given number' do
|
10
37
|
number = "123-123-1234"
|
@@ -18,10 +45,9 @@ describe 'validations' do
|
|
18
45
|
Phony.plausible?('353').should be_false
|
19
46
|
end
|
20
47
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
# end
|
48
|
+
it 'is correct' do
|
49
|
+
Phony.plausible?('+1911').should be_false
|
50
|
+
end
|
25
51
|
it "correctly plausibilizes to#{}do countries" do
|
26
52
|
Phony.plausible?('6327332350').should be_true
|
27
53
|
end
|
@@ -69,14 +95,74 @@ describe 'validations' do
|
|
69
95
|
Phony.plausible?('+41 44 111 22 33', cc: /4(0|1)/, ndc: /4(4|5)/).should be_true
|
70
96
|
end
|
71
97
|
|
98
|
+
context 'Length validation' do
|
99
|
+
it 'works for Swiss cases' do
|
100
|
+
Phony.plausible?('+41 44 111 22 3').should be_false # Not long enough is not ok.
|
101
|
+
# Phony.plausible?('+41 44 111 22 33 4').should be_true # TODO Too long is ok – we don't know about extensions.
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
72
105
|
context 'specific countries' do
|
73
106
|
|
74
|
-
# TODO
|
107
|
+
# TODO: more needs to be done here
|
75
108
|
#
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
109
|
+
it "is correct for Swiss numbers" do
|
110
|
+
Phony.plausible?('+41 44 111 22 33').should be_true
|
111
|
+
Phony.plausible?('+41 44 111 22 334').should be_false
|
112
|
+
Phony.plausible?('+41 44 111 22').should be_false
|
113
|
+
end
|
114
|
+
|
115
|
+
it "is correct for Danish numbers" do
|
116
|
+
Phony.plausible?('+45 44 11 12 23 34').should be_false
|
117
|
+
Phony.plausible?('+45 44 11 12 2').should be_false
|
118
|
+
Phony.plausible?('+45 44 55 22 33').should be_true
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'is correct for egyptian numbers' do
|
122
|
+
Phony.plausible?('+20 800 1234567').should be_true
|
123
|
+
Phony.plausible?('+20 800 12345678').should be_false
|
124
|
+
Phony.plausible?('+20 2 12345678').should be_true
|
125
|
+
Phony.plausible?('+20 2 1234567').should be_false
|
126
|
+
Phony.plausible?('+20 40 12345678').should be_true
|
127
|
+
Phony.plausible?('+20 40 1234567').should be_false
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'is correct for Dutch numbers' do
|
131
|
+
Phony.plausible?('+31 6 12 34 56 78').should be_true
|
132
|
+
Phony.plausible?('+31 6 12 34 56 7').should be_false
|
133
|
+
Phony.plausible?('+31 20 123 5678').should be_true
|
134
|
+
Phony.plausible?('+31 20 123 567').should be_false
|
135
|
+
Phony.plausible?('+31 221 123 567').should be_true
|
136
|
+
Phony.plausible?('+31 221 123 56').should be_false
|
137
|
+
end
|
138
|
+
it 'is correct for Nigerian numbers' do
|
139
|
+
Phony.plausible?('+234 807 766 1234').should be_true
|
140
|
+
Phony.plausible?('+234 807 766 123').should be_false
|
141
|
+
end
|
142
|
+
it 'is correct for Italian numbers' do
|
143
|
+
Phony.plausible?('+39 06 1234 4567').should be_true
|
144
|
+
Phony.plausible?('+39 335 123 4567').should be_true
|
145
|
+
Phony.plausible?('+39 335 123').should be_false
|
146
|
+
end
|
147
|
+
it 'is correct for German numbers' do
|
148
|
+
Phony.plausible?('+49 40 123 45678').should be_true
|
149
|
+
Phony.plausible?('+49 40 123 456789').should be_false
|
150
|
+
Phony.plausible?('+49 171 123 4567').should be_true
|
151
|
+
Phony.plausible?('+49 171 123 45678').should be_false
|
152
|
+
Phony.plausible?('+49 177 123 1234').should be_true
|
153
|
+
Phony.plausible?('+49 176 123 12345').should be_true
|
154
|
+
# Phony.plausible?('+49 991 1234').should be_true # stricter 3 digit ndc rules
|
155
|
+
# Phony.plausible?('+49 2041 123').should be_true # Grandfathered numbers. TODO
|
156
|
+
Phony.plausible?('+49 2041 1234567').should be_true
|
157
|
+
Phony.plausible?('+49 2041 12345689').should be_false
|
158
|
+
Phony.plausible?('+49 31234 123456').should be_true
|
159
|
+
Phony.plausible?('+49 31234 1234567').should be_false
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'is correct for Isralian numbers' do
|
163
|
+
Phony.plausible?('+972 2 123 1234').should be_true
|
164
|
+
Phony.plausible?('+972 59 123 1234').should be_true
|
165
|
+
end
|
80
166
|
it "is correct for US numbers" do
|
81
167
|
# Sorry, still need E164 conform numbers.
|
82
168
|
#
|
@@ -88,6 +174,8 @@ describe 'validations' do
|
|
88
174
|
Phony.plausible?('1-800-692-7753').should be_true
|
89
175
|
Phony.plausible?('1-911').should be_false
|
90
176
|
Phony.plausible?('1-911-123-1234').should be_false
|
177
|
+
Phony.plausible?('143466677777').should be_false # too long
|
178
|
+
Phony.plausible?('143466677').should be_false # too short
|
91
179
|
|
92
180
|
# With string constraints.
|
93
181
|
#
|
@@ -101,7 +189,451 @@ describe 'validations' do
|
|
101
189
|
Phony.plausible?('14346667777', ndc: /434|435/).should be_true
|
102
190
|
Phony.plausible?('14346667777', cc: /[123]/, ndc: /434|435/).should be_true
|
103
191
|
end
|
104
|
-
|
192
|
+
|
193
|
+
it "is correct for Portugese numbers" do
|
194
|
+
Phony.plausible?('+351 800 123456').should be_true
|
195
|
+
Phony.plausible?('+351 90 1234567').should be_true
|
196
|
+
Phony.plausible?('+351 90 123456').should be_false
|
197
|
+
Phony.plausible?('+351 123 1234567').should be_true
|
198
|
+
end
|
199
|
+
|
200
|
+
it "is correct for Russia" do
|
201
|
+
Phony.plausible?('+7 800 2000 600').should be_true
|
202
|
+
Phony.plausible?('+7 960 301 23 45').should be_true
|
203
|
+
Phony.plausible?('+7 800 2000 60').should be_false # too short
|
204
|
+
Phony.plausible?('796030123451').should be_false # too long
|
205
|
+
end
|
206
|
+
|
207
|
+
it "is correct for Austria" do
|
208
|
+
Phony.plausible?('+43 501 1234567890').should be_true
|
209
|
+
Phony.plausible?('+43 501 123456789').should be_false # too short
|
210
|
+
Phony.plausible?('+43 501 12345678901').should be_false # too long
|
211
|
+
end
|
212
|
+
|
213
|
+
it "is correct for Azerbaijan" do
|
214
|
+
Phony.plausible?('+994 12 1234567').should be_true
|
215
|
+
Phony.plausible?('+994 12 12345').should be_false # too short
|
216
|
+
Phony.plausible?('+994 12 12345678').should be_false # too long
|
217
|
+
end
|
218
|
+
|
219
|
+
it "is correct for Albania" do
|
220
|
+
Phony.plausible?('+355 85 123456').should be_true
|
221
|
+
Phony.plausible?('+355 85 12345').should be_false # too short
|
222
|
+
Phony.plausible?('+355 85 1234567').should be_false # too long
|
223
|
+
end
|
224
|
+
|
225
|
+
it "is correct for Angola" do
|
226
|
+
Phony.plausible?('+244 852 123 456').should be_true
|
227
|
+
Phony.plausible?('+244 852 123').should be_false # too short
|
228
|
+
Phony.plausible?('+244 852 123 4567').should be_false # too long
|
229
|
+
end
|
230
|
+
|
231
|
+
it "is correct for Andorra" do
|
232
|
+
Phony.plausible?('+376 712345').should be_true
|
233
|
+
Phony.plausible?('+376 71234').should be_false # too short
|
234
|
+
Phony.plausible?('+376 7123456').should be_false # too long
|
235
|
+
Phony.plausible?('+376 712345').should be_true
|
236
|
+
Phony.plausible?('+376 71234').should be_false # too short
|
237
|
+
Phony.plausible?('+376 7123456').should be_false # too long
|
238
|
+
end
|
239
|
+
|
240
|
+
it "is correct for Netherlands Antilles" do
|
241
|
+
Phony.plausible?('+599 1234567').should be_true
|
242
|
+
Phony.plausible?('+599 123456').should be_false # too short
|
243
|
+
Phony.plausible?('+599 12345678').should be_false # too long
|
244
|
+
end
|
245
|
+
|
246
|
+
it "is correct for Armenia" do
|
247
|
+
Phony.plausible?('+374 12345678').should be_true
|
248
|
+
Phony.plausible?('+374 1234567').should be_false # too short
|
249
|
+
Phony.plausible?('+374 123456789').should be_false # too long
|
250
|
+
end
|
251
|
+
|
252
|
+
it "is correct for Aruba" do
|
253
|
+
Phony.plausible?('+297 52 1234').should be_true
|
254
|
+
Phony.plausible?('+297 52 123').should be_false # too short
|
255
|
+
Phony.plausible?('+297 52 12345').should be_false # too long
|
256
|
+
end
|
257
|
+
|
258
|
+
it 'is correct for Bangladesh' do
|
259
|
+
Phony.plausible?('+880 2 1234567').should be_true
|
260
|
+
Phony.plausible?('+880 2 12345678').should be_false # too long
|
261
|
+
Phony.plausible?('+880 2 123456').should be_false # too short
|
262
|
+
|
263
|
+
Phony.plausible?('+880 9020 12345').should be_true
|
264
|
+
Phony.plausible?('+880 9020 123456').should be_false # too long
|
265
|
+
Phony.plausible?('+880 9020 1234').should be_false # too short
|
266
|
+
|
267
|
+
# ndc with several subscriber number length
|
268
|
+
Phony.plausible?('+880 3035 1234').should be_true
|
269
|
+
Phony.plausible?('+880 3035 123').should be_true
|
270
|
+
Phony.plausible?('+880 3035 12').should be_false # too short
|
271
|
+
Phony.plausible?('+880 3035 12345').should be_false # too long
|
272
|
+
end
|
273
|
+
|
274
|
+
it 'is correct for Bahrain' do
|
275
|
+
Phony.plausible?('+973 1234 5678').should be_true
|
276
|
+
Phony.plausible?('+973 1234 567').should be_false # too short
|
277
|
+
Phony.plausible?('+973 1234 56789').should be_false # too long
|
278
|
+
end
|
279
|
+
|
280
|
+
it 'is correct for Belarus' do
|
281
|
+
Phony.plausible?('+375 152 123456').should be_true
|
282
|
+
Phony.plausible?('+375 152 12345').should be_false # too short
|
283
|
+
Phony.plausible?('+375 152 1234567').should be_false # too long
|
284
|
+
|
285
|
+
Phony.plausible?('+375 800 123').should be_true
|
286
|
+
Phony.plausible?('+375 800 1234').should be_true
|
287
|
+
Phony.plausible?('+375 800 1234567').should be_true
|
288
|
+
Phony.plausible?('+375 800 123456').should be_false
|
289
|
+
Phony.plausible?('+375 800 12345678').should be_false
|
290
|
+
end
|
291
|
+
|
292
|
+
it_is_correct_for 'Belize', :samples => '+501 205 1234'
|
293
|
+
it_is_correct_for 'Benin', :samples => '+229 1234 5678'
|
294
|
+
it_is_correct_for 'Bolivia', :samples => '+591 2 277 2266'
|
295
|
+
it_is_correct_for 'Botswana', :samples => ['+267 80 123 456',
|
296
|
+
'+267 29 567 89',
|
297
|
+
'+267 463 4567',
|
298
|
+
'+267 58 123 45',
|
299
|
+
'+267 7 6712 345',
|
300
|
+
'+267 8 1234 567']
|
301
|
+
it_is_correct_for 'Colombia', :samples => ['+57 1 123 4567', '+57 310 123 4567']
|
302
|
+
it_is_correct_for 'Philippines', :samples => [['+63 2 1234567', '+63 2 1234567890'],
|
303
|
+
'+63 88 1234567',
|
304
|
+
['+63 920 123456', '+63 920 1234567']]
|
305
|
+
|
306
|
+
it_is_correct_for 'Pakistan', :samples => ['+92 21 1234 5678',
|
307
|
+
'+92 22 1234 567',
|
308
|
+
'+92 232 123 456',
|
309
|
+
'+92 30 1234 5678']
|
310
|
+
it_is_correct_for 'Bhutan (Kingdom of)', :samples => '+975 2 889 648'
|
311
|
+
it_is_correct_for 'Brunei Darussalam', :samples => '+673 5 523 876'
|
312
|
+
it_is_correct_for 'Burkina Faso', :samples => '+226 1476 2312'
|
313
|
+
it_is_correct_for 'Burundi', :samples => '+257 1234 5678'
|
314
|
+
it_is_correct_for 'Cameroon', :samples => '+237 7372 8186'
|
315
|
+
it_is_correct_for 'Cape Verde', :samples => '+238 642 3843'
|
316
|
+
it_is_correct_for 'Central African Republic', :samples => '+236 1234 5678'
|
317
|
+
it_is_correct_for 'Chad', :samples => '+235 1234 5678'
|
318
|
+
it_is_correct_for 'Comoros', :samples => ['+269 3901 234', '+269 3401 234']
|
319
|
+
it_is_correct_for 'Congo', :samples => '+242 1234 56789'
|
320
|
+
it_is_correct_for 'Cook Islands', :samples => '+682 71928'
|
321
|
+
it_is_correct_for 'Costa Rica', :samples => '+506 2 234 5678'
|
322
|
+
it_is_correct_for "Côte d'Ivoire", :samples => '+225 9358 8764'
|
323
|
+
it_is_correct_for 'Democratic Republic of Timor-Leste', :samples => ['+670 465 7886', '+670 7465 7886']
|
324
|
+
it_is_correct_for 'Democratic Republic of the Congo', :samples => '+243 8 864 9794'
|
325
|
+
it_is_correct_for 'Diego Garcia', :samples => '+246 123 7686'
|
326
|
+
it_is_correct_for 'Djibouti', :samples => '+253 3671 1431'
|
327
|
+
it_is_correct_for 'Ecuador', :samples => '+593 68 467 4579'
|
328
|
+
it_is_correct_for 'Equatorial Guinea', :samples => ['+240 222 201 123',
|
329
|
+
'+240 335 201 123']
|
330
|
+
it_is_correct_for 'Eritrea', :samples => '+291 6 334 475'
|
331
|
+
it_is_correct_for 'Ethiopia', :samples => '+251 89 558 3197'
|
332
|
+
it_is_correct_for 'Falkland Islands (Malvinas)', :samples => '+500 28494'
|
333
|
+
it_is_correct_for 'Faroe Islands', :samples => '+298 969 597'
|
334
|
+
it_is_correct_for 'Fiji (Republic of)', :samples => '+679 998 2441'
|
335
|
+
it_is_correct_for 'French Guiana (French Department of)', :samples => '+594 594 123 456'
|
336
|
+
it_is_correct_for "French Polynesia (Territoire français d'outre-mer)", :samples => '+689 872 784'
|
337
|
+
it_is_correct_for 'Gabonese Republic', :samples => '+241 1 627 739'
|
338
|
+
it_is_correct_for 'Gambia', :samples => '+220 989 5148'
|
339
|
+
it_is_correct_for 'Georgia', :samples => ['+995 220 123 45',
|
340
|
+
'+995 32 123 4567',
|
341
|
+
'+995 342 123 456',
|
342
|
+
'+995 596 123 456']
|
343
|
+
it_is_correct_for 'Greece', :samples => ['+30 21 4234 5678',
|
344
|
+
'+30 24 4234 5678',
|
345
|
+
'+30 50 3457 1234',
|
346
|
+
'+30 69 0123 4567',
|
347
|
+
'+30 70 0123 4567',
|
348
|
+
'+30 800 100 1234',
|
349
|
+
'+30 801 100 1234',
|
350
|
+
'+30 807 100 1234',
|
351
|
+
'+30 896 100 1234',
|
352
|
+
'+30 901 123 4565',
|
353
|
+
'+30 909 123 4565']
|
354
|
+
it_is_correct_for 'Greenland', :samples => '+299 922 954'
|
355
|
+
it_is_correct_for 'Guadeloupe (French Department of)', :samples => '+590 123 456 789'
|
356
|
+
it_is_correct_for 'Guatemala (Republic of)', :samples => ['+502 19 123 456 789',
|
357
|
+
'+502 2 123 4567']
|
358
|
+
it_is_correct_for 'Guinea', :samples => '+224 1234 5678'
|
359
|
+
it_is_correct_for 'Guinea-Bissau', :samples => '+245 728 6998'
|
360
|
+
it_is_correct_for 'Guyana', :samples => '+592 263 1234'
|
361
|
+
it_is_correct_for 'Honduras (Republic of)', :samples => '+504 12 961 637'
|
362
|
+
it_is_correct_for 'Indonesia', :samples => ['+62 13 123',
|
363
|
+
'+62 13 123 456',
|
364
|
+
'+62 174 12',
|
365
|
+
'+62 174 12 345',
|
366
|
+
'+62 177 12',
|
367
|
+
'+62 177 1212 3456',
|
368
|
+
'+62 178 123',
|
369
|
+
'+62 178 123 45',
|
370
|
+
'+62 21 123 45',
|
371
|
+
'+62 21 1234 5567',
|
372
|
+
'+62 22 123 45',
|
373
|
+
'+62 22 123 4567',
|
374
|
+
'+62 4 311 234',
|
375
|
+
'+62 4 3112 3456',
|
376
|
+
['+62 6 221 2345', '+62 6 2212 3456'],
|
377
|
+
'+62 70 123 456',
|
378
|
+
['+62 71 123 456', '+62 71 123 4567'],
|
379
|
+
'+62 810 123 456',
|
380
|
+
'+62 810 1234 5678',
|
381
|
+
'+62 820 123 456',
|
382
|
+
'+62 870 123 45',
|
383
|
+
'+62 877 123 456',
|
384
|
+
'+62 881 123 456',
|
385
|
+
'+62 881 1234 5656',
|
386
|
+
'+62 9 1234 567',
|
387
|
+
'+62 9 123 456 789']
|
388
|
+
it_is_correct_for 'Iraq', :samples => ['+964 1 123 4567',
|
389
|
+
'+964 21 113 456',
|
390
|
+
'+964 71 1234 5678']
|
391
|
+
it_is_correct_for 'Japan', :samples => ['+81 3 1234 5678',
|
392
|
+
'+81 120 123 456',
|
393
|
+
'+81 11 1234 567',
|
394
|
+
'+81 123 123 456',
|
395
|
+
'+81 1267 123 45',
|
396
|
+
'+81 90 1234 5678']
|
397
|
+
it_is_correct_for 'Jordan (Hashemite Kingdom of)', :samples => ['+962 800 123 45',
|
398
|
+
'+962 2 620 1234',
|
399
|
+
'+962 7 1234 5678',
|
400
|
+
'+962 7 4661 2345',
|
401
|
+
'+962 900 123 45',
|
402
|
+
'+962 85 123 456',
|
403
|
+
'+962 70 123 456',
|
404
|
+
'+962 6250 1456',
|
405
|
+
'+962 8790 1456']
|
406
|
+
it_is_correct_for 'Kiribati (Republic of)', :samples => '+686 31993'
|
407
|
+
it_is_correct_for "Democratic People's Republic of Korea", :samples => ['+850 2 123 45',
|
408
|
+
'+850 2 123 456 789',
|
409
|
+
'+850 2 381 2356',
|
410
|
+
#'+850 2 8801 1234 5678 1256',
|
411
|
+
'+850 191 123 4567']
|
412
|
+
it_is_correct_for 'Kuwait (State of)', :samples => ['+965 2345 6789', '+965 181 2345' ]
|
413
|
+
it_is_correct_for 'Kyrgyzstan', :samples => ['+996 312 212 345',
|
414
|
+
'+996 315 212 345',
|
415
|
+
'+996 3131 212 34',
|
416
|
+
'+996 3946 212 34',
|
417
|
+
'+996 50 123 4567',
|
418
|
+
'+996 52 123 4567',
|
419
|
+
'+996 58 123 4567',
|
420
|
+
'+996 800 123 456']
|
421
|
+
it_is_correct_for "Lao People's Democratic Republic", :samples => ['+856 96 443 333',
|
422
|
+
'+856 30 443 3334',
|
423
|
+
'+856 20 4433 3334']
|
424
|
+
it_is_correct_for 'Latvia', :samples => ['+371 801 234 56',
|
425
|
+
'+371 637 234 56',
|
426
|
+
'+371 294 123 45']
|
427
|
+
it_is_correct_for 'Lebanon', :samples => ['+961 1 123 456',
|
428
|
+
'+961 4 123 456',
|
429
|
+
'+961 3 123 456',
|
430
|
+
'+961 70 123 456',
|
431
|
+
'+961 90 123 456',
|
432
|
+
'+961 81 123 456']
|
433
|
+
it_is_correct_for 'Lesotho', :samples => '+266 7612 6866'
|
434
|
+
it_is_correct_for 'Liberia', :samples => [['+231 2 123 4567', '+231 4 123 456']]
|
435
|
+
it_is_correct_for 'Madagascar', :samples => ['+261 20 012 345 678',
|
436
|
+
'+261 20 124 3456',
|
437
|
+
'+261 512 345 678']
|
438
|
+
it_is_correct_for 'Malawi', :samples => ['+265 1725 123',
|
439
|
+
'+265 213 456 789',
|
440
|
+
'+265 9123 456',
|
441
|
+
'+265 991 123 456']
|
442
|
+
it_is_correct_for 'Maldives (Republic of)', :samples => '+960 928 8399'
|
443
|
+
it_is_correct_for 'Mali', :samples => '+223 1117 9812'
|
444
|
+
|
445
|
+
it 'is correct for Malaysia' do
|
446
|
+
Phony.plausible?('+60 14 123 1234').should be_true
|
447
|
+
Phony.plausible?('+60 14 1234 1234').should be_false
|
448
|
+
Phony.plausible?('+60 14 1234 12').should be_false # too short
|
449
|
+
Phony.plausible?('+60 14 1234 12345').should be_false # too long
|
450
|
+
end
|
451
|
+
|
452
|
+
it_is_correct_for 'Marshall Islands (Republic of the)', :samples => '+692 372 7183'
|
453
|
+
it_is_correct_for 'Martinique (French Department of)', :samples => '+596 596 123 456'
|
454
|
+
it_is_correct_for 'Mauritania', :samples => '+222 1234 5678'
|
455
|
+
it_is_correct_for 'Mauritius', :samples => '+230 695 2277'
|
456
|
+
it_is_correct_for 'Micronesia (Federated States of)', :samples => '+691 766 7914'
|
457
|
+
it_is_correct_for 'Moldova', :samples => ['+373 800 123 45',
|
458
|
+
'+373 22 123 345',
|
459
|
+
'+373 241 123 45',
|
460
|
+
'+373 605 123 45',
|
461
|
+
'+373 803 123 45']
|
462
|
+
it_is_correct_for 'Montenegro', :samples => ['+382 80 123 456',
|
463
|
+
['+382 20 123 45', '+382 20 123 456'],
|
464
|
+
'+382 32 123 456',
|
465
|
+
'+382 78 103 456',
|
466
|
+
'+382 63 123',
|
467
|
+
'+382 63 123 456 7890',
|
468
|
+
'+382 77 103 456',
|
469
|
+
'+382 94 103 456',
|
470
|
+
'+382 88 103 456',
|
471
|
+
'+382 68 12',
|
472
|
+
'+382 68 12 1234 5678',
|
473
|
+
'+382 68 432 163',
|
474
|
+
'+382 69 705 542',
|
475
|
+
'+382 70 123',
|
476
|
+
'+382 70 123 456 7890']
|
477
|
+
it_is_correct_for 'Namibia', :samples => ['+264 6751 613 24',
|
478
|
+
'+264 67 175 890',
|
479
|
+
'+264 63 088 612 345',
|
480
|
+
'+264 85 1234 567']
|
481
|
+
it_is_correct_for 'Nauru (Republic of)', :samples => '+674 239 8387'
|
482
|
+
it_is_correct_for 'Nepal', :samples => ['+977 1 434 5678',
|
483
|
+
'+977 10 123 456',
|
484
|
+
'+977 98 1234 5678']
|
485
|
+
it_is_correct_for "New Caledonia (Territoire français d'outre-mer)", :samples => '+687 546 835'
|
486
|
+
it_is_correct_for 'Nicaragua', :samples => '+505 12 345 678'
|
487
|
+
it_is_correct_for 'Niger', :samples => '+227 1234 5678'
|
488
|
+
it_is_correct_for 'Niue', :samples => '+683 3791'
|
489
|
+
it_is_correct_for 'Oman', :samples => ['+968 24 423 123',
|
490
|
+
'+968 25 423 123']
|
491
|
+
it_is_correct_for 'Palau (Republic of)', :samples => '+680 483 7871'
|
492
|
+
it_is_correct_for 'Panama (Republic of)', :samples => ['+507 800 1234',
|
493
|
+
'+507 6 123 4567',
|
494
|
+
'+507 2 123 456']
|
495
|
+
it_is_correct_for 'Papua New Guinea', :samples => ['+675 3 123 567',
|
496
|
+
'+675 180 1234',
|
497
|
+
'+675 80 123 456',
|
498
|
+
'+675 91 123 456',
|
499
|
+
'+675 16 123 45',
|
500
|
+
'+675 184 1234 5678',
|
501
|
+
'+675 170 12',
|
502
|
+
'+675 189 1',
|
503
|
+
'+675 270 1234',
|
504
|
+
'+675 275 1234',
|
505
|
+
'+675 279 12',
|
506
|
+
'+675 115 1234 5678']
|
507
|
+
it_is_correct_for 'Paraguay (Republic of)', :samples => [['+595 21 123 456', '+595 21 123 4567'],
|
508
|
+
'+595 345 123 456',
|
509
|
+
'+595 96 161 1234']
|
510
|
+
it_is_correct_for 'Qatar', :samples => ['+974 1245 123 456',
|
511
|
+
'+974 26 134 56',
|
512
|
+
'+974 33 123 456',
|
513
|
+
'+974 44 412 456',
|
514
|
+
'+974 800 12 34',
|
515
|
+
'+974 900 12 34',
|
516
|
+
'+974 92 123',
|
517
|
+
'+974 97 123']
|
518
|
+
it_is_correct_for 'Reunion / Mayotte (new)', :samples => '+262 29527 69649'
|
519
|
+
it_is_correct_for 'Saint Helena', :samples => '+290 5134'
|
520
|
+
it_is_correct_for 'Saint Pierre and Miquelon (Collectivité territoriale de la République française)', :samples => '+508 474 714'
|
521
|
+
it_is_correct_for 'Samoa (Independent State of)', :samples => ['+685 800 123',
|
522
|
+
'+685 61 123',
|
523
|
+
'+685 721 2345',
|
524
|
+
'+685 830 123',
|
525
|
+
'+685 601 234',
|
526
|
+
'+685 841 2345']
|
527
|
+
it_is_correct_for 'San Marino', :samples => ['+378 800 123',
|
528
|
+
'+378 800 123 4567',
|
529
|
+
'+378 012 345',
|
530
|
+
'+378 012 345 6789',
|
531
|
+
'+378 512 345',
|
532
|
+
'+378 512 345 6789']
|
533
|
+
it_is_correct_for 'Sao Tome and Principe', :samples => ['+239 2 220 012',
|
534
|
+
'+239 9 920 012']
|
535
|
+
it_is_correct_for 'Saudi Arabia (Kingdom of)', :samples => '+966 5 296 3727'
|
536
|
+
it_is_correct_for 'Senegal', :samples => '+221 1234 56789'
|
537
|
+
it_is_correct_for 'Serbia', :samples => ['+381 800 123 45',
|
538
|
+
['+381 10 123 45', '+381 10 123 456'],
|
539
|
+
['+381 11 123 456', '+381 11 123 4567'],
|
540
|
+
'+381 72 123 456',
|
541
|
+
'+381 60 123',
|
542
|
+
'+381 60 123 4567',
|
543
|
+
'+381 42 123 456',
|
544
|
+
'+381 9 123 4567',
|
545
|
+
'+381 60 123',
|
546
|
+
'+381 60 123 456 7890',
|
547
|
+
'+381 70 123 456']
|
548
|
+
it_is_correct_for 'Sierra Leone', :samples => '+232 42 393 972'
|
549
|
+
it_is_correct_for 'Solomon Islands', :samples => '+677 97851'
|
550
|
+
it_is_correct_for 'Somali Democratic Republic', :samples => ['+252 1034 123 45',
|
551
|
+
'+252 1313 123',
|
552
|
+
'+252 160 12 34',
|
553
|
+
'+252 500 123 45',
|
554
|
+
'+252 67 1234 567']
|
555
|
+
it_is_correct_for 'South Sudan', :samples => ['+211 123 212 345',
|
556
|
+
'+211 973 212 345']
|
557
|
+
it_is_correct_for 'Suriname (Republic of)', :samples => ['+597 212 345', '+597 612 3456']
|
558
|
+
it_is_correct_for 'Swaziland', :samples => ['+268 2207 1234', '+268 550 1234']
|
559
|
+
it_is_correct_for 'Syrian Arab Republic', :samples => ['+963 11 123 4567',
|
560
|
+
'+963 31 123 4567',
|
561
|
+
'+963 15 731 234',
|
562
|
+
'+963 9 1234 5678']
|
563
|
+
it_is_correct_for 'Taiwan', :samples => ['+886 18 123 456',
|
564
|
+
'+886 612 123 4567',
|
565
|
+
'+886 2 1234 5678',
|
566
|
+
'+886 3 123 4567',
|
567
|
+
'+886 33 123 456',
|
568
|
+
'+886 827 123 45',
|
569
|
+
'+886 412 1234',
|
570
|
+
['+886 90 123 456', '+886 90 123 4567'],
|
571
|
+
'+886 94 991 345']
|
572
|
+
it_is_correct_for 'Tajikistan', :samples => ['+992 3130 123 45',
|
573
|
+
'+992 331700 123',
|
574
|
+
'+992 372 123 345',
|
575
|
+
'+992 505 123 456',
|
576
|
+
'+992 973 123 456',
|
577
|
+
'+992 474 456 123']
|
578
|
+
it_is_correct_for 'Thailand', :samples => ['+6621231234',
|
579
|
+
'+6636123123',
|
580
|
+
'+66851234567']
|
581
|
+
it_is_correct_for 'Togolese Republic', :samples => '+228 1234 5678'
|
582
|
+
it_is_correct_for 'Tokelau', :samples => '+690 3 291'
|
583
|
+
it_is_correct_for 'Tonga (Kingdom of)', :samples => ['+676 20 123',
|
584
|
+
'+676 84 123',
|
585
|
+
'+676 77 123 45',
|
586
|
+
'+676 89 123 45']
|
587
|
+
it_is_correct_for 'Turkmenistan', :samples => ['+993 12 456 789',
|
588
|
+
'+993 131 456 78',
|
589
|
+
'+993 1392 4567',
|
590
|
+
'+993 6 123 4567']
|
591
|
+
it_is_correct_for 'Tuvalu', :samples => '+688 93742'
|
592
|
+
it_is_correct_for 'Uzbekistan (Republic of)', :samples => '+998 78 867 4419'
|
593
|
+
it_is_correct_for 'Vanuatu (Republic of)', :samples => ['+678 7216 123', '+678 26 123']
|
594
|
+
it_is_correct_for 'Lybia', :samples => ['+218 205 123 45',
|
595
|
+
'+218 22 123 456',
|
596
|
+
'+218 21 1234 456',
|
597
|
+
'+218 91 1234 456']
|
598
|
+
it_is_correct_for 'Mongolia', :samples => ['+976 11 123 45',
|
599
|
+
['+976 121 12 34', '+976 121 12 345'],
|
600
|
+
'+976 70 123 456',
|
601
|
+
'+976 75 123 456',
|
602
|
+
'+976 88 123 456',
|
603
|
+
'+976 50 123 456']
|
604
|
+
it_is_correct_for 'Mozambique', :samples => ['+258 600 123 456',
|
605
|
+
'+258 251 123 45',
|
606
|
+
'+258 82 1234 456',
|
607
|
+
'+258 7 1234 4567']
|
608
|
+
it_is_correct_for 'Ukraine', :samples => ['+380 800 123 456',
|
609
|
+
'+380 312 123 456',
|
610
|
+
'+380 32 2123 456',
|
611
|
+
'+380 3259 123 45',
|
612
|
+
'+380 32606 1234',
|
613
|
+
'+380 981 234 567']
|
614
|
+
it_is_correct_for 'United Arab Emirates', :samples => ['+971 800 12',
|
615
|
+
'+971 800 12 345 6789',
|
616
|
+
'+971 2 123 4567',
|
617
|
+
'+971 50 641 2345',
|
618
|
+
'+971 600 641 234',
|
619
|
+
'+971 500 641 234',
|
620
|
+
'+971 200 641 234']
|
621
|
+
it_is_correct_for 'Uruguay (Eastern Republic of)', :samples => ['+598 800 123 45',
|
622
|
+
'+598 2 012 3456',
|
623
|
+
'+598 21 123 456',
|
624
|
+
'+598 909 123 45',
|
625
|
+
'+598 93 123 456',
|
626
|
+
'+598 908 123 45',
|
627
|
+
'+598 805 123 45']
|
628
|
+
it_is_correct_for 'Yemen', :samples => [['+967 1 234 567', '+967 1 234 5678'],
|
629
|
+
'+967 7 234 567',
|
630
|
+
'+967 77 123 4567',
|
631
|
+
'+967 58 1234']
|
632
|
+
it_is_correct_for 'Zimbabwe', :samples => [['+263 2582 123 456', '+263 2582 123'],
|
633
|
+
['+263 147 123 456', '+263 147 123'],
|
634
|
+
['+263 270 123 456', '+263 270 123 45'],
|
635
|
+
'+263 86 1235 4567']
|
636
|
+
|
105
637
|
end
|
106
638
|
|
107
639
|
end
|