validate_zipcode 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -0
- data/LIST.md +51 -0
- data/lib/validate_zipcode/regex.rb +245 -0
- data/lib/validate_zipcode/version.rb +1 -1
- data/validate_zipcode.gemspec +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: a552eef65208f9c3c7611dfcffe7fac7fac95fa2
|
4
|
+
data.tar.gz: bcb009998483bc8e5e12c59fb66acee444c8a68a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1388626d8bb2914694f535555982b8cb064147ad28a4cad675b3acaff7918f8e1455e6389e9297a52de09075d6b4964ed046f5e5d100544425f360e4dbe5e84f
|
7
|
+
data.tar.gz: d7423fb6de79a3897ed6ae3a43bc710c88bdf8471f8daf1eb8258ceabf6bc6e75fa15bfbb89beeabbb38ff4f15749d8e833e668dbc473474df0f58b875485626
|
data/.gitignore
CHANGED
data/LIST.md
CHANGED
@@ -3,52 +3,101 @@
|
|
3
3
|
| Country | Identification | Format | Link |
|
4
4
|
|:-------:|:------------:|:-----------:|:-----------:|
|
5
5
|
| Afghanistan | AF | 1001 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/afgEn.pdf) |
|
6
|
+
| Aland Islands | AX | 22100 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/alaEn.pdf) |
|
6
7
|
| Albania | AL | 1001 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/albEn.pdf) |
|
7
8
|
| Algeria | DZ | 16027 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/dzaEn.pdf) |
|
9
|
+
| American Samoa | AS | 90410 or 10118-0229 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/asmEn.pdf) |
|
10
|
+
| Argentina | AR | Y5900FNF | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/argEn.pdf) |
|
11
|
+
| Armenia | AM | 0002 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/armEn.pdf) |
|
8
12
|
| Australia | AU | 3171 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/ausEn.pdf) |
|
9
13
|
| Austria | AT | 1220 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/autEn.pdf) |
|
14
|
+
| Azerbaijan | AZ | 1000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/azeEn.pdf) |
|
10
15
|
| Bangladesh | BD | 1340 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/bgdEn.pdf) |
|
11
16
|
| Belarus | BY | 220050 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/blrEn.pdf) |
|
12
17
|
| Belgium | BE | 2610 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/belEn.pdf) |
|
18
|
+
| Bhutan | BT | 11001 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/btnEn.pdf) |
|
13
19
|
| Bolivia | BO | 1716 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/bolEn.pdf) |
|
20
|
+
| Bosnia and Herzegovina | BA | 71000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/bihEn.pdf) |
|
14
21
|
| Brazil | BR | 35001-345 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/braEn.pdf) |
|
22
|
+
| Brunei Darussalam | BN | BT2328 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/brnEn.pdf) |
|
15
23
|
| Bulgaria | BG | 4000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/bgrEn.pdf) |
|
16
24
|
| Cabo Verde | CV | 7600 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/cpvEn.pdf) |
|
25
|
+
| Cambodia | KH | 12203 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/khmEn.pdf) |
|
17
26
|
| Canada | CA | H3Z 2Y7 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/canEn.pdf) |
|
18
27
|
| Chile | CL | 872-0019 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/chlEn.pdf) |
|
19
28
|
| China | CN | 200082 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/chnEn.pdf) |
|
29
|
+
| Christmas Island | CX | 1000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/cxrEn.pdf) |
|
30
|
+
| Cocos (Keeling) Islands | CC | 1000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/cckEn.pdf) |
|
20
31
|
| Colombia | CO | 110221 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/colEn.pdf) |
|
21
32
|
| Costa Rica | CR | 40501 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/criEn.pdf) |
|
22
33
|
| Croatia | HR | 1000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/hrvEn.pdf) |
|
23
34
|
| Cuba | CU | 10600 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/cubEn.pdf) |
|
24
35
|
| Cyprus | CY | 2008 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/cypEn.pdf) |
|
36
|
+
| Czech Republic | CZ | 100 00 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/czeEn.pdf) |
|
25
37
|
| Denmark | DK | 8660 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/dnkEn.pdf) |
|
26
38
|
| Deutsch or Germany | DE | 81545 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/deuEn.pdf) |
|
39
|
+
| Dominican Republic | DO | 11903 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/domEn.pdf) |
|
40
|
+
| Ecuador | EC | 170515 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/ecuEn.pdf) |
|
41
|
+
| Egypt | EG | 12411 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/egyEn.pd) |
|
42
|
+
| El Salvador | SV | 1120 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/slvEn.pdf) |
|
27
43
|
| Estonia | EE | 69501 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/estEn.pdf) |
|
28
44
|
| Ethiopia | ET | 1000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/ethEn.pdf) |
|
29
45
|
| Finland | FI | 50100 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/finEn.pdf) |
|
30
46
|
| France | FR | 75007 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/fraEn.pdf) |
|
47
|
+
| French Guiana | GF | 97300 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/gufEn.pdf) |
|
48
|
+
| French Polynesia | PF | 98709 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/pyfEn.pdf) |
|
31
49
|
| Georgia | GE | 0100 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/geoEn.pdf) |
|
32
50
|
| Greece | GR | 151 24 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/grcEn.pdf) |
|
51
|
+
| Greenland | GL | 1000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/grlEn.pdf) |
|
52
|
+
| Guadeloupe | GP | 97100 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/glpEn.pdf) |
|
53
|
+
| Guatemala | GT | 09001 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/gtmEn.pdf) |
|
33
54
|
| Guinea-Bissau | GW | 1000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/gnbEn.pdf) |
|
55
|
+
| Haiti | HT | HT6120 or 6120 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/htiEn.pdf) |
|
34
56
|
| Heard Island and McDonald Islands | HM | 3177 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/hmdEn.pdf) |
|
57
|
+
| Holy See (Vatican) | VA | 00120 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/vatEn.pdf) |
|
58
|
+
| Honduras | HN | CM1102 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/hndEn.pdf) |
|
35
59
|
| Hungary | HU | 1037 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/hunEn.pdf) |
|
60
|
+
| Iceland | IS | 220 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/islEn.pdf) |
|
36
61
|
| India | IN | 110034 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/indEn.pdf) |
|
37
62
|
| Indonesia | ID | 40198 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/idnEn.pdf) |
|
63
|
+
| Iran | IR | 1193653471 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/irnEn.pdf) |
|
38
64
|
| Iraq | IQ | 61002 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/irqEn.pdf) |
|
39
65
|
| Israel | IL | 94142 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/isrEn.pdf) |
|
40
66
|
| Italy | IT | 20090 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/itaEn.pdf) |
|
41
67
|
| Japan | JP | 208–0032 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/jpnEn.pdf) |
|
68
|
+
| Jordan | JO | 11937 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/jorEn.pdf) |
|
42
69
|
| Kazakhstan | KZ | 040900 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/kazEn.pdf) |
|
70
|
+
| Kenya | KE | 20100 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/kenEn.pdf) |
|
71
|
+
| Republic of Korea | KR | 42007 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/korEn.pdf) |
|
72
|
+
| Kuwait | KW | 54541 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/kwtEn.pdf) |
|
43
73
|
| Kyrgyzstan | KG | 720001 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/kgzEn.pdf) |
|
74
|
+
| Laos | LA | 01160 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/laoEn.pdf) |
|
75
|
+
| Latvia | LV | 1073 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/lvaEn.pdf) |
|
76
|
+
| Lebanon | LB | 2038 3054 or 2038 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/lbnEn.pdf) |
|
77
|
+
| Lesotho | LS | 100 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/lsoEn.pdf) |
|
44
78
|
| Liberia | LR | 1000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/lbrEn.pdf) |
|
45
79
|
| Liechtenstein | LI | 2544 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/lieEn.pdf) |
|
80
|
+
| Lithuania | LT | 04340 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/ltuEn.pdf) |
|
81
|
+
| Luxembourg | LU | 1234 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/luxEn.pdf) |
|
46
82
|
| Macedonia | MK | 1020 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mkdEn.pdf) |
|
83
|
+
| Madagascar | MG | 501 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mdgEn.pdf) |
|
84
|
+
| Malaysia | MY | 43000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mysEn.pdf) |
|
85
|
+
| Maldives | MV | 20026 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mdvEn.pdf) |
|
86
|
+
| Malta | MT | ZTN 1073 or ZTN1073| [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mltEn.pdf) |
|
47
87
|
| Marshall Islands | MH | 96970 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mhlEn.pdf) |
|
88
|
+
| Martinique | MQ | 97200 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mtqEn.pdf) |
|
89
|
+
| Mauritius | MU | 42602 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/musEn.pdf) |
|
90
|
+
| Mayotte | YT | 97600 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mytEn.pdf) |
|
48
91
|
| Mexico | MX | 02860 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mexEn.pdf) |
|
92
|
+
| Federated States of Micronesia | FM | 96941 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/fsmEn.pdf) |
|
93
|
+
| Republic of Moldova | MD | 2012 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mdaEn.pdf) |
|
49
94
|
| Monaco | MC | 98000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mcoEn.pdf) |
|
50
95
|
| Mongolia | MN | 15141 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mngEn.pdf) |
|
96
|
+
| Montenegro | CS | 81000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mneEn.pdf) |
|
97
|
+
| Montserrat | MS | MSR1110 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/msrEn.pdf) |
|
98
|
+
| Morocco | MA | 53000 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/marEn.pdf) |
|
51
99
|
| Mozambique | MZ | 1100 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mozEn.pdf) |
|
100
|
+
| Myanmar | MM | 11181 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/mmrEn.pdf) |
|
52
101
|
| Namibia | NA | 26890 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/namEn.pdf) |
|
53
102
|
| Nepal | NP | 44601 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/nplEn.pdf) |
|
54
103
|
| Niger | NE | 8001 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/nerEn.pdf) |
|
@@ -83,3 +132,5 @@
|
|
83
132
|
| Viet Nam | VN | 123456 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/vnmEn.pdf) |
|
84
133
|
| Virgin Islands of the United States of America | VI | 00801 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/virEn.pdf) |
|
85
134
|
| Zambia | ZM | 50100 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/zmbEn.pdf) |
|
135
|
+
|
136
|
+
***We are using as documentation the files found in [Universal Postal Union](http://www.upu.int/en.html).***
|
@@ -5,6 +5,11 @@ module ValidateZipcode
|
|
5
5
|
match = zipcode =~ /^([0-9]{4})$/
|
6
6
|
match == 0 ? true : false
|
7
7
|
end
|
8
|
+
# Aland Islands
|
9
|
+
def self.AX(zipcode)
|
10
|
+
match = zipcode =~ /^([0-9]{5})$/
|
11
|
+
match == 0 ? true : false
|
12
|
+
end
|
8
13
|
# Albania
|
9
14
|
def self.AL(zipcode)
|
10
15
|
match = zipcode =~ /^([0-9]{4})$/
|
@@ -15,6 +20,21 @@ module ValidateZipcode
|
|
15
20
|
match = zipcode =~ /^([0-9]{5})$/
|
16
21
|
match == 0 ? true : false
|
17
22
|
end
|
23
|
+
# American Samoa
|
24
|
+
def self.AS(zipcode)
|
25
|
+
match = zipcode =~ /^([0-9]{5})$|([0-9]{9})$|([0-9]{5}-[0-9]{4})$/
|
26
|
+
match == 0 ? true : false
|
27
|
+
end
|
28
|
+
# Argentina
|
29
|
+
def self.AR(zipcode)
|
30
|
+
match = zipcode =~ /^([a-zA-Z][0-9]{4}[a-zA-Z]{3})$/
|
31
|
+
match == 0 ? true : false
|
32
|
+
end
|
33
|
+
# Armenia
|
34
|
+
def self.AM(zipcode)
|
35
|
+
match = zipcode =~ /^([0-9]{4})$/
|
36
|
+
match == 0 ? true : false
|
37
|
+
end
|
18
38
|
# Australia
|
19
39
|
def self.AU(zipcode)
|
20
40
|
match = zipcode =~ /^([0-9]{4})$/
|
@@ -25,6 +45,11 @@ module ValidateZipcode
|
|
25
45
|
match = zipcode =~ /^([0-9]{4})$/
|
26
46
|
match == 0 ? true : false
|
27
47
|
end
|
48
|
+
# Azerbaijan
|
49
|
+
def self.AZ(zipcode)
|
50
|
+
match = zipcode =~ /^([0-9]{4})$/
|
51
|
+
match == 0 ? true : false
|
52
|
+
end
|
28
53
|
# Bangladesh
|
29
54
|
def self.BD(zipcode)
|
30
55
|
match = zipcode =~ /^([0-9]{4})$/
|
@@ -40,16 +65,31 @@ module ValidateZipcode
|
|
40
65
|
match = zipcode =~ /^([0-9]{4})$/
|
41
66
|
match == 0 ? true : false
|
42
67
|
end
|
68
|
+
# Bhutan
|
69
|
+
def self.BT(zipcode)
|
70
|
+
match = zipcode =~ /^([0-9]{5})$/
|
71
|
+
match == 0 ? true : false
|
72
|
+
end
|
43
73
|
# Bolivia
|
44
74
|
def self.BO(zipcode)
|
45
75
|
match = zipcode =~ /^([0-9]{4})$/
|
46
76
|
match == 0 ? true : false
|
47
77
|
end
|
78
|
+
# BA Bosnia and Herzegovina
|
79
|
+
def self.BA(zipcode)
|
80
|
+
match = zipcode =~ /^([0-9]{5})$/
|
81
|
+
match == 0 ? true : false
|
82
|
+
end
|
48
83
|
# Brazil
|
49
84
|
def self.BR(zipcode)
|
50
85
|
match = zipcode =~ /^([0-9]{5}-[0-9]{3})$|([0-9]{8})$/
|
51
86
|
match == 0 ? true : false
|
52
87
|
end
|
88
|
+
# Brunei Darussalam
|
89
|
+
def self.BN(zipcode)
|
90
|
+
match = zipcode =~ /^([a-zA-Z]{2}[0-9]{4})$/
|
91
|
+
match == 0 ? true : false
|
92
|
+
end
|
53
93
|
# Bulgaria
|
54
94
|
def self.BG(zipcode)
|
55
95
|
match = zipcode =~ /^([0-9]{4})$/
|
@@ -60,6 +100,11 @@ module ValidateZipcode
|
|
60
100
|
match = zipcode =~ /^([0-9]{4})$/
|
61
101
|
match == 0 ? true : false
|
62
102
|
end
|
103
|
+
# Cambodia
|
104
|
+
def self.KH(zipcode)
|
105
|
+
match = zipcode =~ /^([0-9]{5})$/
|
106
|
+
match == 0 ? true : fals
|
107
|
+
end
|
63
108
|
# Canada
|
64
109
|
def self.CA(zipcode)
|
65
110
|
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])/
|
@@ -75,6 +120,16 @@ module ValidateZipcode
|
|
75
120
|
match = zipcode =~ /^([0-9]{6})$/
|
76
121
|
match == 0 ? true : false
|
77
122
|
end
|
123
|
+
# Christmas Island
|
124
|
+
def self.CX(zipcode)
|
125
|
+
match = zipcode =~ /^([0-9]{4})$/
|
126
|
+
match == 0 ? true : false
|
127
|
+
end
|
128
|
+
# Cocos (Keeling) Islands
|
129
|
+
def self.CC(zipcode)
|
130
|
+
match = zipcode =~ /^([0-9]{4})$/
|
131
|
+
match == 0 ? true : false
|
132
|
+
end
|
78
133
|
# Colombia
|
79
134
|
def self.CO(zipcode)
|
80
135
|
match = zipcode =~ /^([0-9]{6})$/
|
@@ -100,6 +155,11 @@ module ValidateZipcode
|
|
100
155
|
match = zipcode =~ /^([0-9]{4})$/
|
101
156
|
match == 0 ? true : false
|
102
157
|
end
|
158
|
+
# Czech Republic
|
159
|
+
def self.CZ(zipcode)
|
160
|
+
match = zipcode =~ /^([0-9]{3}[ ][0-9]{2})$|([0-9]{5})$/
|
161
|
+
match == 0 ? true : false
|
162
|
+
end
|
103
163
|
# Denmark
|
104
164
|
def self.DK(zipcode)
|
105
165
|
match = zipcode =~ /^([0-9]{4})$/
|
@@ -110,6 +170,26 @@ module ValidateZipcode
|
|
110
170
|
match = zipcode =~ /^([0-9]{5})$/
|
111
171
|
match == 0 ? true : false
|
112
172
|
end
|
173
|
+
# Dominican Republic
|
174
|
+
def self.DO(zipcode)
|
175
|
+
match = zipcode =~ /^([0-9]{5})$/
|
176
|
+
match == 0 ? true : false
|
177
|
+
end
|
178
|
+
# Ecuador
|
179
|
+
def self.EC(zipcode)
|
180
|
+
match = zipcode =~ /^([0-9]{6})$/
|
181
|
+
match == 0 ? true : false
|
182
|
+
end
|
183
|
+
# Egypt
|
184
|
+
def self.EG(zipcode)
|
185
|
+
match = zipcode =~ /^([0-9]{5})$/
|
186
|
+
match == 0 ? true : false
|
187
|
+
end
|
188
|
+
# El Salvador
|
189
|
+
def self.SV(zipcode)
|
190
|
+
match = zipcode =~ /^([0-9]{4})$/
|
191
|
+
match == 0 ? true : false
|
192
|
+
end
|
113
193
|
# Estonia
|
114
194
|
def self.EE(zipcode)
|
115
195
|
match = zipcode =~ /^([0-9]{5})$/
|
@@ -130,6 +210,16 @@ module ValidateZipcode
|
|
130
210
|
match = zipcode =~ /^([0-9]{5})$/
|
131
211
|
match == 0 ? true : false
|
132
212
|
end
|
213
|
+
# French Guiana
|
214
|
+
def self.GF(zipcode)
|
215
|
+
match = zipcode =~ /^([0-9]{5})$/
|
216
|
+
match == 0 ? true : false
|
217
|
+
end
|
218
|
+
# French Polynesia
|
219
|
+
def self.PF(zipcode)
|
220
|
+
match = zipcode =~ /^([0-9]{5})$/
|
221
|
+
match == 0 ? true : false
|
222
|
+
end
|
133
223
|
# Georgia
|
134
224
|
def self.GE(zipcode)
|
135
225
|
match = zipcode =~ /^([0-9]{4})$/
|
@@ -140,21 +230,56 @@ module ValidateZipcode
|
|
140
230
|
match = zipcode =~ /^([0-9]{3}[ ][0-9]{2})$|([0-9]{5})$|([0-9]{3}-[0-9]{2})$/
|
141
231
|
match == 0 ? true : false
|
142
232
|
end
|
233
|
+
# Greenland
|
234
|
+
def self.GL(zipcode)
|
235
|
+
match = zipcode =~ /^([0-9]{4})$/
|
236
|
+
match == 0 ? true : false
|
237
|
+
end
|
238
|
+
# Guadeloupe
|
239
|
+
def self.GP(zipcode)
|
240
|
+
match = zipcode =~ /^([0-9]{5})$/
|
241
|
+
match == 0 ? true : false
|
242
|
+
end
|
243
|
+
# Guatemala
|
244
|
+
def self.GT(zipcode)
|
245
|
+
match = zipcode =~ /^([0-9]{5})$/
|
246
|
+
match == 0 ? true : false
|
247
|
+
end
|
143
248
|
# Guinea-Bissau
|
144
249
|
def self.GW(zipcode)
|
145
250
|
match = zipcode =~ /^([0-9]{4})$/
|
146
251
|
match == 0 ? true : false
|
147
252
|
end
|
253
|
+
# Haiti
|
254
|
+
def self.HT(zipcode)
|
255
|
+
match = zipcode =~ /^([hH][tT][0-9]{4})$|([0-9]{4})$/
|
256
|
+
match == 0 ? true : false
|
257
|
+
end
|
148
258
|
# Heard Island and McDonald Islands
|
149
259
|
def self.HM(zipcode)
|
150
260
|
match = zipcode =~ /^([0-9]{4})$/
|
151
261
|
match == 0 ? true : false
|
152
262
|
end
|
263
|
+
# Holy See (Vatican)
|
264
|
+
def self.VA(zipcode)
|
265
|
+
match = zipcode =~ /^([0-9]{5})$/
|
266
|
+
match == 0 ? true : false
|
267
|
+
end
|
268
|
+
# Honduras
|
269
|
+
def self.HN(zipcode)
|
270
|
+
match = zipcode =~ /^([a-zA-Z]{2}[0-9]{4})$/
|
271
|
+
match == 0 ? true : false
|
272
|
+
end
|
153
273
|
# Hungary
|
154
274
|
def self.HU(zipcode)
|
155
275
|
match = zipcode =~ /^([0-9]{4})$/
|
156
276
|
match == 0 ? true : false
|
157
277
|
end
|
278
|
+
# Iceland
|
279
|
+
def self.IS(zipcode)
|
280
|
+
match = zipcode =~ /^([0-9]{3})$/
|
281
|
+
match == 0 ? true : false
|
282
|
+
end
|
158
283
|
# India
|
159
284
|
def self.IN(zipcode)
|
160
285
|
match = zipcode =~ /^([0-9]{6})$/
|
@@ -165,6 +290,11 @@ module ValidateZipcode
|
|
165
290
|
match = zipcode =~ /^([0-9]{5})$/
|
166
291
|
match == 0 ? true : false
|
167
292
|
end
|
293
|
+
# Iran
|
294
|
+
def self.IR(zipcode)
|
295
|
+
match = zipcode =~ /^([0-9]{10})$/
|
296
|
+
match == 0 ? true : false
|
297
|
+
end
|
168
298
|
# Iraq
|
169
299
|
def self.IQ(zipcode)
|
170
300
|
match = zipcode =~ /^([0-9]{5})$/
|
@@ -185,16 +315,56 @@ module ValidateZipcode
|
|
185
315
|
match = zipcode =~ /^([0-9]{3}-[0-9]{4})$|([0-9]{7})$/
|
186
316
|
match == 0 ? true : false
|
187
317
|
end
|
318
|
+
# Jordan
|
319
|
+
def self.JO(zipcode)
|
320
|
+
match = zipcode =~ /^([0-9]{5})$/
|
321
|
+
match == 0 ? true : false
|
322
|
+
end
|
188
323
|
# Kazakhstan
|
189
324
|
def self.KZ(zipcode)
|
190
325
|
match = zipcode =~ /^([0-9]{6})$/
|
191
326
|
match == 0 ? true : false
|
192
327
|
end
|
328
|
+
# Kenya
|
329
|
+
def self.KE(zipcode)
|
330
|
+
match = zipcode =~ /^([0-9]{5})$/
|
331
|
+
match == 0 ? true : false
|
332
|
+
end
|
333
|
+
# KR - Republic of Korea
|
334
|
+
def self.KR(zipcode)
|
335
|
+
match = zipcode =~ /^([0-9]{5})$/
|
336
|
+
match == 0 ? true : false
|
337
|
+
end
|
338
|
+
# Kuwait
|
339
|
+
def self.KW(zipcode)
|
340
|
+
match = zipcode =~ /^([0-9]{5})$/
|
341
|
+
match == 0 ? true : false
|
342
|
+
end
|
193
343
|
# Kyrgyzstan
|
194
344
|
def self.KG(zipcode)
|
195
345
|
match = zipcode =~ /^([0-9]{6})$/
|
196
346
|
match == 0 ? true : false
|
197
347
|
end
|
348
|
+
# Laos
|
349
|
+
def self.LA(zipcode)
|
350
|
+
match = zipcode =~ /^([0-9]{5})$/
|
351
|
+
match == 0 ? true : false
|
352
|
+
end
|
353
|
+
# Latvia
|
354
|
+
def self.LV(zipcode)
|
355
|
+
match = zipcode =~ /^([0-9]{4})$/
|
356
|
+
match == 0 ? true : false
|
357
|
+
end
|
358
|
+
# Lebanon
|
359
|
+
def self.LB(zipcode)
|
360
|
+
match = zipcode =~ /^([0-9]{4}[ ][0-9]{4})$|([0-9]{4})$/
|
361
|
+
match == 0 ? true : false
|
362
|
+
end
|
363
|
+
# Lesotho
|
364
|
+
def self.LS(zipcode)
|
365
|
+
match = zipcode =~ /^([0-9]{3})$/
|
366
|
+
match == 0 ? true : false
|
367
|
+
end
|
198
368
|
# Liberia
|
199
369
|
def self.LR(zipcode)
|
200
370
|
match = zipcode =~ /^([0-9]{4})$/
|
@@ -205,21 +375,76 @@ module ValidateZipcode
|
|
205
375
|
match = zipcode =~ /^([0-9]{4})$/
|
206
376
|
match == 0 ? true : false
|
207
377
|
end
|
378
|
+
# Lithuania
|
379
|
+
def self.LT(zipcode)
|
380
|
+
match = zipcode =~ /^([0-9]{5})$/
|
381
|
+
match == 0 ? true : false
|
382
|
+
end
|
383
|
+
# Luxembourg
|
384
|
+
def self.LU(zipcode)
|
385
|
+
match = zipcode =~ /^([0-9]{4})$/
|
386
|
+
match == 0 ? true : false
|
387
|
+
end
|
208
388
|
# Macedonia
|
209
389
|
def self.MK(zipcode)
|
210
390
|
match = zipcode =~ /^([0-9]{4})$/
|
211
391
|
match == 0 ? true : false
|
212
392
|
end
|
393
|
+
# Madagascar
|
394
|
+
def self.MG(zipcode)
|
395
|
+
match = zipcode =~ /^([0-9]{3})$/
|
396
|
+
match == 0 ? true : false
|
397
|
+
end
|
398
|
+
# Malaysia
|
399
|
+
def self.MY(zipcode)
|
400
|
+
match = zipcode =~ /^([0-9]{5})$/
|
401
|
+
match == 0 ? true : false
|
402
|
+
end
|
403
|
+
# Maldives
|
404
|
+
def self.MV(zipcode)
|
405
|
+
match = zipcode =~ /^([0-9]{5})$/
|
406
|
+
match == 0 ? true : false
|
407
|
+
end
|
408
|
+
# Malta
|
409
|
+
def self.MT(zipcode)
|
410
|
+
match = zipcode =~ /^([a-zA-Z]{3}[ ][0-9]{4})$|([a-zA-Z]{3}[0-9]{4})$/
|
411
|
+
match == 0 ? true : false
|
412
|
+
end
|
213
413
|
# Marshall Islands
|
214
414
|
def self.MH(zipcode)
|
215
415
|
match = zipcode =~ /^([0-9]{5})$/
|
216
416
|
match == 0 ? true : false
|
217
417
|
end
|
418
|
+
# Martinique
|
419
|
+
def self.MQ(zipcode)
|
420
|
+
match = zipcode =~ /^([0-9]{5})$/
|
421
|
+
match == 0 ? true : false
|
422
|
+
end
|
423
|
+
# Mauritius
|
424
|
+
def self.MU(zipcode)
|
425
|
+
match = zipcode =~ /^([0-9]{5})$/
|
426
|
+
match == 0 ? true : false
|
427
|
+
end
|
428
|
+
# Mayotte
|
429
|
+
def self.YT(zipcode)
|
430
|
+
match = zipcode =~ /^([0-9]{5})$/
|
431
|
+
match == 0 ? true : false
|
432
|
+
end
|
218
433
|
# Mexico
|
219
434
|
def self.MX(zipcode)
|
220
435
|
match = zipcode =~ /^([0-9]{5})$/
|
221
436
|
match == 0 ? true : false
|
222
437
|
end
|
438
|
+
# Federated States of Micronesia
|
439
|
+
def self.FM(zipcode)
|
440
|
+
match = zipcode =~ /^([0-9]{5})$/
|
441
|
+
match == 0 ? true : false
|
442
|
+
end
|
443
|
+
# Republic of Moldova
|
444
|
+
def self.MD(zipcode)
|
445
|
+
match = zipcode =~ /^([0-9]{4})$/
|
446
|
+
match == 0 ? true : false
|
447
|
+
end
|
223
448
|
# Monaco
|
224
449
|
def self.MC(zipcode)
|
225
450
|
match = zipcode =~ /^([0-9]{5})$/
|
@@ -230,11 +455,31 @@ module ValidateZipcode
|
|
230
455
|
match = zipcode =~ /^([0-9]{5})$/
|
231
456
|
match == 0 ? true : false
|
232
457
|
end
|
458
|
+
# Montenegro
|
459
|
+
def self.CS(zipcode)
|
460
|
+
match = zipcode =~ /^([0-9]{5})$/
|
461
|
+
match == 0 ? true : false
|
462
|
+
end
|
463
|
+
# Montserrat
|
464
|
+
def self.MS(zipcode)
|
465
|
+
match = zipcode =~ /^([mM][sS][rR][0-9]{4})$|([0-9]{4})$/
|
466
|
+
match == 0 ? true : false
|
467
|
+
end
|
468
|
+
# Morocco
|
469
|
+
def self.MA(zipcode)
|
470
|
+
match = zipcode =~ /^([0-9]{5})$/
|
471
|
+
match == 0 ? true : false
|
472
|
+
end
|
233
473
|
# Mozambique
|
234
474
|
def self.MZ(zipcode)
|
235
475
|
match = zipcode =~ /^([0-9]{4})$/
|
236
476
|
match == 0 ? true : false
|
237
477
|
end
|
478
|
+
# Myanmar
|
479
|
+
def self.MM(zipcode)
|
480
|
+
match = zipcode =~ /^([0-9]{5})$/
|
481
|
+
match == 0 ? true : false
|
482
|
+
end
|
238
483
|
# Namibia
|
239
484
|
def self.NA(zipcode)
|
240
485
|
match = zipcode =~ /^([0-9]{5})$/
|
data/validate_zipcode.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["hosseinramon@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{ Zip code validation for Rails. }
|
13
|
-
spec.description = %q{ Adds validation methods considering different country zip code formats. Currently, we can validate
|
13
|
+
spec.description = %q{ Adds validation methods considering different country zip code formats. Currently, we can validate 130 countries. }
|
14
14
|
spec.homepage = "https://github.com/RamonHossein/validate_zipcode"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
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.3.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-08-
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: " Adds validation methods considering different country zip code formats.
|
98
|
-
Currently, we can validate
|
98
|
+
Currently, we can validate 130 countries. "
|
99
99
|
email:
|
100
100
|
- hosseinramon@gmail.com
|
101
101
|
executables: []
|