validate_zipcode 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LIST.md +43 -1
- data/lib/validate_zipcode/regex.rb +224 -13
- data/lib/validate_zipcode/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13cbd851f081d14f9fb4ced90abb90bfa56b2eef
|
4
|
+
data.tar.gz: 24e53119158d5e4bfae5c87250f490668c326149
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56e3ba8ac95c55dd27e1032583f4de37a2f6f32d4d670fc3f908e6748d8ef02a778bbd55adc456dc927c4815474afcf23dabf4eb6448d9e997ff3a3fb09fc33e
|
7
|
+
data.tar.gz: 7cab0a790ac834e11e007a12f5e84983800ecd68840d46cd12101c40b913d41cf99f22068ba7492599c68657cce8b8aef6c492d94f5bf3e27fa28564aac9d6be
|
data/LIST.md
CHANGED
@@ -2,11 +2,53 @@
|
|
2
2
|
|
3
3
|
| Country | Identification | Format | Link |
|
4
4
|
|:-------:|:------------:|:-----------:|:-----------:|
|
5
|
+
| Algeria | DZ | 16027 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/dzaEn.pdf) |
|
6
|
+
| Australia | AU | 3171 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/ausEn.pdf) |
|
7
|
+
| Austria | AT | 1220 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/autEn.pdf) |
|
8
|
+
| Bolivia | BO | 1716 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/bolEn.pdf) |
|
5
9
|
| Brazil | BR | 35001-345 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/braEn.pdf) |
|
10
|
+
| Bulgaria | BG | 4000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/bgrEn.pdf) |
|
11
|
+
| Canada | CA | H3Z 2Y7 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/canEn.pdf) |
|
12
|
+
| Chile | CL | 872-0019 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/chlEn.pdf) |
|
6
13
|
| China | CN | 200082 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/chnEn.pdf) |
|
7
|
-
|
|
14
|
+
| Colombia | CO | 110221 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/colEn.pdf) |
|
15
|
+
| Croatia | HR | 1000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/hrvEn.pdf) |
|
16
|
+
| Cuba | CU | 10600 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/cubEn.pdf) |
|
17
|
+
| Denmark | DK | 8660 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/dnkEn.pdf) |
|
18
|
+
| Deutsch or Germany | DE | 81545 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/deuEn.pdf) |
|
19
|
+
| Estonia | EE | 69501 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/estEn.pdf) |
|
20
|
+
| Ethiopia | ET | 1000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/ethEn.pdf) |
|
21
|
+
| Finland | FI | 50100 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/finEn.pdf) |
|
8
22
|
| France | FR | 75007 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/fraEn.pdf) |
|
23
|
+
| Greece | GR | 151 24 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/grcEn.pdf) |
|
24
|
+
| India | IN | 110034 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/indEn.pdf) |
|
25
|
+
| Indonesia | ID | 40198 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/idnEn.pdf) |
|
26
|
+
| Iraq | IQ | 61002 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/irqEn.pdf) |
|
27
|
+
| Israel | IL | 94142 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/isrEn.pdf) |
|
9
28
|
| Italy | IT | 20090 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/itaEn.pdf) |
|
10
29
|
| Japan | JP | 208–0032 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/jpnEn.pdf) |
|
30
|
+
| Kazakhstan | KZ | 040900 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/kazEn.pdf) |
|
31
|
+
| Mexico | MX | 02860 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mexEn.pdf) |
|
32
|
+
| Monaco | MC | 98000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mcoEn.pdf) |
|
33
|
+
| Paraguay | PY | 1536 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/pryEn.pdf) |
|
34
|
+
| Peru | PE | 15074 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/perEn.pdf) |
|
35
|
+
| Portugal | PT | 2725-079 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/prtEn.pdf) |
|
36
|
+
| Romania | RO | 060274 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/rouEn.pdf) |
|
37
|
+
| Russian | RU | 125075 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/rusEn.pdf) |
|
38
|
+
| Saudi Arabia | SA | 12643 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/sauEn.pdf) |
|
39
|
+
| Senegal | SE | 12500 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/senEn.pdf) |
|
40
|
+
| Singapore | SG | 546080 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/sgpEn.pdf) |
|
41
|
+
| Slovenia | SI | 4000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/svnEn.pdf) |
|
42
|
+
| South Africa | ZA | 0083 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/zafEn.pdf) |
|
11
43
|
| Spain | ES | 28001 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/espEn.pdf) |
|
44
|
+
| Sri Lanka | LK | 20000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/lkaEn.pdf) |
|
45
|
+
| Tajikistan | TJ | 735450 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/tjkEn.pdf) |
|
46
|
+
| Thailand | TH | 10150 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/thaEn.pdf) |
|
47
|
+
| Tunisia | TN | 1002 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/tunEn.pdf) |
|
48
|
+
| Turkey | TR | 06101 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/turEn.pdf) |
|
49
|
+
| Turkmenistan | TM | 744000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/tkmEn.pdf) |
|
50
|
+
| Ukraine | UA | 15432 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/ukrEn.pdf) |
|
12
51
|
| United States | US | 90410 or 10118-0229 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/usaEn.pdf) |
|
52
|
+
| Uzbekistan | UZ | 140101 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/uzbEn.pdf) |
|
53
|
+
| Venezuela | VE | 1010 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/venEn.pdf) |
|
54
|
+
| Zambia | ZM | 50100 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/zmbEn.pdf) |
|
@@ -1,43 +1,254 @@
|
|
1
1
|
module ValidateZipcode
|
2
2
|
module Regex
|
3
|
-
|
4
|
-
|
3
|
+
# Algeria
|
4
|
+
def self.DZ(zipcode)
|
5
|
+
match = zipcode =~ /^([0-9]{5})$/
|
6
|
+
match == 0 ? true : false
|
7
|
+
end
|
8
|
+
# Australia
|
9
|
+
def self.AU(zipcode)
|
10
|
+
match = zipcode =~ /^([0-9]{4})$/
|
11
|
+
match == 0 ? true : false
|
12
|
+
end
|
13
|
+
# Austria
|
14
|
+
def self.AT(zipcode)
|
15
|
+
match = zipcode =~ /^([0-9]{4})$/
|
16
|
+
match == 0 ? true : false
|
17
|
+
end
|
18
|
+
# Bolivia
|
19
|
+
def self.BO(zipcode)
|
20
|
+
match = zipcode =~ /^([0-9]{4})$/
|
5
21
|
match == 0 ? true : false
|
6
22
|
end
|
7
|
-
|
23
|
+
# Brazil
|
8
24
|
def self.BR(zipcode)
|
9
25
|
match = zipcode =~ /^([0-9]{5}-[0-9]{3})$|([0-9]{8})$/
|
10
26
|
match == 0 ? true : false
|
11
27
|
end
|
12
|
-
|
13
|
-
def self.
|
28
|
+
# Bulgaria
|
29
|
+
def self.BG(zipcode)
|
30
|
+
match = zipcode =~ /^([0-9]{4})$/
|
31
|
+
match == 0 ? true : false
|
32
|
+
end
|
33
|
+
# Canada
|
34
|
+
def self.CA(zipcode)
|
35
|
+
match = zipcode =~ /^([a-zA-Z][0-9][a-zA-Z][ ][0-9][a-zA-Z][0-9])$|([a-zA-Z][0-9][a-zA-Z][0-9][a-zA-Z][0-9])$|([a-zA-Z][0-9][a-zA-Z]-[0-9][a-zA-Z][0-9])/
|
36
|
+
match == 0 ? true : false
|
37
|
+
end
|
38
|
+
# Chile
|
39
|
+
def self.CL(zipcode)
|
40
|
+
match = zipcode =~ /^([0-9]{3}-[0-9]{4})$|([0-9]{7})$/
|
41
|
+
match == 0 ? true : false
|
42
|
+
end
|
43
|
+
# China
|
44
|
+
def self.CN(zipcode)
|
45
|
+
match = zipcode =~ /^([0-9]{6})$/
|
46
|
+
match == 0 ? true : false
|
47
|
+
end
|
48
|
+
# Colombia
|
49
|
+
def self.CO(zipcode)
|
50
|
+
match = zipcode =~ /^([0-9]{6})$/
|
51
|
+
match == 0 ? true : false
|
52
|
+
end
|
53
|
+
# Croatia
|
54
|
+
def self.HR(zipcode)
|
14
55
|
match = zipcode =~ /^([0-9]{5})$/
|
15
56
|
match == 0 ? true : false
|
16
57
|
end
|
17
|
-
|
18
|
-
def self.
|
58
|
+
# Cuba
|
59
|
+
def self.CU(zipcode)
|
19
60
|
match = zipcode =~ /^([0-9]{5})$/
|
20
61
|
match == 0 ? true : false
|
21
62
|
end
|
22
|
-
|
63
|
+
# Denmark
|
64
|
+
def self.DK(zipcode)
|
65
|
+
match = zipcode =~ /^([0-9]{4})$/
|
66
|
+
match == 0 ? true : false
|
67
|
+
end
|
68
|
+
# Deutsch or Germany
|
23
69
|
def self.DE(zipcode)
|
24
70
|
match = zipcode =~ /^([0-9]{5})$/
|
25
71
|
match == 0 ? true : false
|
26
72
|
end
|
27
|
-
|
28
|
-
def self.
|
73
|
+
# Estonia
|
74
|
+
def self.EE(zipcode)
|
29
75
|
match = zipcode =~ /^([0-9]{5})$/
|
30
76
|
match == 0 ? true : false
|
31
77
|
end
|
32
|
-
|
33
|
-
def self.
|
78
|
+
# Ethiopia
|
79
|
+
def self.ET(zipcode)
|
80
|
+
match = zipcode =~ /^([0-9]{4})$/
|
81
|
+
match == 0 ? true : false
|
82
|
+
end
|
83
|
+
# Finland
|
84
|
+
def self.FI(zipcode)
|
85
|
+
match = zipcode =~ /^([0-9]{5})$/
|
86
|
+
match == 0 ? true : false
|
87
|
+
end
|
88
|
+
# France
|
89
|
+
def self.FR(zipcode)
|
90
|
+
match = zipcode =~ /^([0-9]{5})$/
|
91
|
+
match == 0 ? true : false
|
92
|
+
end
|
93
|
+
# Greece
|
94
|
+
def self.GR(zipcode)
|
95
|
+
match = zipcode =~ /^([0-9]{3}[ ][0-9]{2})$|([0-9]{5})$|([0-9]{3}-[0-9]{2})$/
|
96
|
+
match == 0 ? true : false
|
97
|
+
end
|
98
|
+
# India
|
99
|
+
def self.IN(zipcode)
|
34
100
|
match = zipcode =~ /^([0-9]{6})$/
|
35
101
|
match == 0 ? true : false
|
36
102
|
end
|
37
|
-
|
103
|
+
# Indonesia
|
104
|
+
def self.ID(zipcode)
|
105
|
+
match = zipcode =~ /^([0-9]{5})$/
|
106
|
+
match == 0 ? true : false
|
107
|
+
end
|
108
|
+
# Iraq
|
109
|
+
def self.IQ(zipcode)
|
110
|
+
match = zipcode =~ /^([0-9]{5})$/
|
111
|
+
match == 0 ? true : false
|
112
|
+
end
|
113
|
+
# Israel
|
114
|
+
def self.IL(zipcode)
|
115
|
+
match = zipcode =~ /^([0-9]{5})$/
|
116
|
+
match == 0 ? true : false
|
117
|
+
end
|
118
|
+
# Italy
|
119
|
+
def self.IT(zipcode)
|
120
|
+
match = zipcode =~ /^([0-9]{5})$/
|
121
|
+
match == 0 ? true : false
|
122
|
+
end
|
123
|
+
# Japan
|
38
124
|
def self.JP(zipcode)
|
39
125
|
match = zipcode =~ /^([0-9]{3}-[0-9]{4})$|([0-9]{7})$/
|
40
126
|
match == 0 ? true : false
|
41
127
|
end
|
128
|
+
# Kazakhstan
|
129
|
+
def self.KZ(zipcode)
|
130
|
+
match = zipcode =~ /^([0-9]{6})$/
|
131
|
+
match == 0 ? true : false
|
132
|
+
end
|
133
|
+
# Mexico
|
134
|
+
def self.MX(zipcode)
|
135
|
+
match = zipcode =~ /^([0-9]{5})$/
|
136
|
+
match == 0 ? true : false
|
137
|
+
end
|
138
|
+
# Monaco
|
139
|
+
def self.MC(zipcode)
|
140
|
+
match = zipcode =~ /^([0-9]{5})$/
|
141
|
+
match == 0 ? true : false
|
142
|
+
end
|
143
|
+
# Paraguay
|
144
|
+
def self.PY(zipcode)
|
145
|
+
match = zipcode =~ /^([0-9]{4})$/
|
146
|
+
match == 0 ? true : false
|
147
|
+
end
|
148
|
+
# Peru
|
149
|
+
def self.PE(zipcode)
|
150
|
+
match = zipcode =~ /^([0-9]{5})$/
|
151
|
+
match == 0 ? true : false
|
152
|
+
end
|
153
|
+
# Portugal
|
154
|
+
def self.PT(zipcode)
|
155
|
+
match = zipcode =~ /^([0-9]{4}-[0-9]{3})$|([0-9]{7})$/
|
156
|
+
match == 0 ? true : false
|
157
|
+
end
|
158
|
+
# Romania
|
159
|
+
def self.RO(zipcode)
|
160
|
+
match = zipcode =~ /^([0-9]{6})$/
|
161
|
+
match == 0 ? true : false
|
162
|
+
end
|
163
|
+
# Russian
|
164
|
+
def self.RU(zipcode)
|
165
|
+
match = zipcode =~ /^([0-9]{6})$/
|
166
|
+
match == 0 ? true : false
|
167
|
+
end
|
168
|
+
# Saudi Arabia
|
169
|
+
def self.SA(zipcode)
|
170
|
+
match = zipcode =~ /^([0-9]{5})$/
|
171
|
+
match == 0 ? true : false
|
172
|
+
end
|
173
|
+
# Senegal
|
174
|
+
def self.SN(zipcode)
|
175
|
+
match = zipcode =~ /^([0-9]{5})$/
|
176
|
+
match == 0 ? true : false
|
177
|
+
end
|
178
|
+
# Singapore
|
179
|
+
def self.SG(zipcode)
|
180
|
+
match = zipcode =~ /^([0-9]{5})$/
|
181
|
+
match == 0 ? true : false
|
182
|
+
end
|
183
|
+
# Slovenia
|
184
|
+
def self.SI(zipcode)
|
185
|
+
match = zipcode =~ /^([0-9]{4})$/
|
186
|
+
match == 0 ? true : false
|
187
|
+
end
|
188
|
+
# South Africa
|
189
|
+
def self.ZA(zipcode)
|
190
|
+
match = zipcode =~ /^([0-9]{4})$/
|
191
|
+
match == 0 ? true : false
|
192
|
+
end
|
193
|
+
# Spain
|
194
|
+
def self.ES(zipcode)
|
195
|
+
match = zipcode =~ /^([0-9]{5})$/
|
196
|
+
match == 0 ? true : false
|
197
|
+
end
|
198
|
+
# Sri Lanka
|
199
|
+
def self.LK(zipcode)
|
200
|
+
match = zipcode =~ /^([0-9]{5})$/
|
201
|
+
match == 0 ? true : false
|
202
|
+
end
|
203
|
+
# Tajikistan
|
204
|
+
def self.TJ(zipcode)
|
205
|
+
match = zipcode =~ /^([0-9]{6})$/
|
206
|
+
match == 0 ? true : false
|
207
|
+
end
|
208
|
+
# Thailand
|
209
|
+
def self.TH(zipcode)
|
210
|
+
match = zipcode =~ /^([0-9]{5})$/
|
211
|
+
match == 0 ? true : false
|
212
|
+
end
|
213
|
+
# Tunisia
|
214
|
+
def self.TN(zipcode)
|
215
|
+
match = zipcode =~ /^([0-9]{4})$/
|
216
|
+
match == 0 ? true : false
|
217
|
+
end
|
218
|
+
# Turkey
|
219
|
+
def self.TR(zipcode)
|
220
|
+
match = zipcode =~ /^([0-9]{5})$/
|
221
|
+
match == 0 ? true : false
|
222
|
+
end
|
223
|
+
# Turkmenistan
|
224
|
+
def self.TM(zipcode)
|
225
|
+
match = zipcode =~ /^([0-9]{6})$/
|
226
|
+
match == 0 ? true : false
|
227
|
+
end
|
228
|
+
# Ukraine
|
229
|
+
def self.UA(zipcode)
|
230
|
+
match = zipcode =~ /^([0-9]{5})$/
|
231
|
+
match == 0 ? true : false
|
232
|
+
end
|
233
|
+
# United Stade
|
234
|
+
def self.US(zipcode)
|
235
|
+
match = zipcode =~ /^([0-9]{5})$|([0-9]{9})$|([0-9]{5}-[0-9]{4})$/
|
236
|
+
match == 0 ? true : false
|
237
|
+
end
|
238
|
+
# Uzbekistan
|
239
|
+
def self.UZ(zipcode)
|
240
|
+
match = zipcode =~ /^([0-9]{6})$/
|
241
|
+
match == 0 ? true : false
|
242
|
+
end
|
243
|
+
# Venezuela
|
244
|
+
def self.VE(zipcode)
|
245
|
+
match = zipcode =~ /^([0-9]{4})$/
|
246
|
+
match == 0 ? true : false
|
247
|
+
end
|
248
|
+
# Zambia
|
249
|
+
def self.ZM(zipcode)
|
250
|
+
match = zipcode =~ /^([0-9]{5})$/
|
251
|
+
match == 0 ? true : false
|
252
|
+
end
|
42
253
|
end
|
43
254
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validate_zipcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RamonHossein
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.5.1
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Zip code validation for Rails.
|