lib/validate_zipcode/regex.rb in validate_zipcode-1.2.0 vs lib/validate_zipcode/regex.rb in validate_zipcode-1.2.1
- old
+ new
@@ -1,7 +1,17 @@
module ValidateZipcode
module Regex
+ # Afghanistan
+ def self.AF(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
+ # Albania
+ def self.AL(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
# Algeria
def self.DZ(zipcode)
match = zipcode =~ /^([0-9]{5})$/
match == 0 ? true : false
end
@@ -13,10 +23,25 @@
# Austria
def self.AT(zipcode)
match = zipcode =~ /^([0-9]{4})$/
match == 0 ? true : false
end
+ # Bangladesh
+ def self.BD(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
+ # Belarus
+ def self.BY(zipcode)
+ match = zipcode =~ /^([0-9]{6})$/
+ match == 0 ? true : false
+ end
+ # Belgium
+ def self.BE(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
# Bolivia
def self.BO(zipcode)
match = zipcode =~ /^([0-9]{4})$/
match == 0 ? true : false
end
@@ -28,10 +53,15 @@
# Bulgaria
def self.BG(zipcode)
match = zipcode =~ /^([0-9]{4})$/
match == 0 ? true : false
end
+ # Cabo Verde
+ def self.CV(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
# Canada
def self.CA(zipcode)
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])/
match == 0 ? true : false
end
@@ -48,20 +78,30 @@
# Colombia
def self.CO(zipcode)
match = zipcode =~ /^([0-9]{6})$/
match == 0 ? true : false
end
+ # Costa Rica
+ def self.CR(zipcode)
+ match = zipcode =~ /^([0-9]{5})$/
+ match == 0 ? true : false
+ end
# Croatia
def self.HR(zipcode)
match = zipcode =~ /^([0-9]{5})$/
match == 0 ? true : false
end
# Cuba
def self.CU(zipcode)
match = zipcode =~ /^([0-9]{5})$/
match == 0 ? true : false
end
+ # Cyprus
+ def self.CY(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
# Denmark
def self.DK(zipcode)
match = zipcode =~ /^([0-9]{4})$/
match == 0 ? true : false
end
@@ -88,15 +128,35 @@
# France
def self.FR(zipcode)
match = zipcode =~ /^([0-9]{5})$/
match == 0 ? true : false
end
+ # Georgia
+ def self.GE(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
# Greece
def self.GR(zipcode)
match = zipcode =~ /^([0-9]{3}[ ][0-9]{2})$|([0-9]{5})$|([0-9]{3}-[0-9]{2})$/
match == 0 ? true : false
end
+ # Guinea-Bissau
+ def self.GW(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
+ # Heard Island and McDonald Islands
+ def self.HM(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
+ # Hungary
+ def self.HU(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
# India
def self.IN(zipcode)
match = zipcode =~ /^([0-9]{6})$/
match == 0 ? true : false
end
@@ -128,30 +188,95 @@
# Kazakhstan
def self.KZ(zipcode)
match = zipcode =~ /^([0-9]{6})$/
match == 0 ? true : false
end
+ # Kyrgyzstan
+ def self.KG(zipcode)
+ match = zipcode =~ /^([0-9]{6})$/
+ match == 0 ? true : false
+ end
+ # Liberia
+ def self.LR(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
+ # Liechtenstein
+ def self.LI(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
+ # Macedonia
+ def self.MK(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
+ # Marshall Islands
+ def self.MH(zipcode)
+ match = zipcode =~ /^([0-9]{5})$/
+ match == 0 ? true : false
+ end
# Mexico
def self.MX(zipcode)
match = zipcode =~ /^([0-9]{5})$/
match == 0 ? true : false
end
# Monaco
def self.MC(zipcode)
match = zipcode =~ /^([0-9]{5})$/
match == 0 ? true : false
end
+ # Mongolia
+ def self.MN(zipcode)
+ match = zipcode =~ /^([0-9]{5})$/
+ match == 0 ? true : false
+ end
+ # Mozambique
+ def self.MZ(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
+ # Namibia
+ def self.NA(zipcode)
+ match = zipcode =~ /^([0-9]{5})$/
+ match == 0 ? true : false
+ end
+ # Nepal
+ def self.NP(zipcode)
+ match = zipcode =~ /^([0-9]{5})$/
+ match == 0 ? true : false
+ end
+ # Niger
+ def self.NE(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
+ # New Zealand (including the Ross dependency)
+ def self.NZ(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
+ # Norway
+ def self.NO(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
# Paraguay
def self.PY(zipcode)
match = zipcode =~ /^([0-9]{4})$/
match == 0 ? true : false
end
# Peru
def self.PE(zipcode)
match = zipcode =~ /^([0-9]{5})$/
match == 0 ? true : false
end
+ # Philippines
+ def self.PH(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
# Portugal
def self.PT(zipcode)
match = zipcode =~ /^([0-9]{4}-[0-9]{3})$|([0-9]{7})$/
match == 0 ? true : false
end
@@ -175,11 +300,11 @@
match = zipcode =~ /^([0-9]{5})$/
match == 0 ? true : false
end
# Singapore
def self.SG(zipcode)
- match = zipcode =~ /^([0-9]{5})$/
+ match = zipcode =~ /^([0-9]{6})$/
match == 0 ? true : false
end
# Slovenia
def self.SI(zipcode)
match = zipcode =~ /^([0-9]{4})$/
@@ -198,20 +323,40 @@
# Sri Lanka
def self.LK(zipcode)
match = zipcode =~ /^([0-9]{5})$/
match == 0 ? true : false
end
+ # Sudan
+ def self.SD(zipcode)
+ match = zipcode =~ /^([0-9]{5})$/
+ match == 0 ? true : false
+ end
+ # Svalbard and Jan Mayen Island
+ def self.SJ(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
+ # Switzerland
+ def self.CH(zipcode)
+ match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
# Tajikistan
def self.TJ(zipcode)
match = zipcode =~ /^([0-9]{6})$/
match == 0 ? true : false
end
# Thailand
def self.TH(zipcode)
match = zipcode =~ /^([0-9]{5})$/
match == 0 ? true : false
end
+ # Trinidad and Tobago
+ def self.TT(zipcode)
+ match = zipcode =~ /^([0-9]{6})$/
+ match == 0 ? true : false
+ end
# Tunisia
def self.TN(zipcode)
match = zipcode =~ /^([0-9]{4})$/
match == 0 ? true : false
end
@@ -241,9 +386,19 @@
match == 0 ? true : false
end
# Venezuela
def self.VE(zipcode)
match = zipcode =~ /^([0-9]{4})$/
+ match == 0 ? true : false
+ end
+ # Viet Nam
+ def self.VN(zipcode)
+ match = zipcode =~ /^([0-9]{6})$/
+ match == 0 ? true : false
+ end
+ # Virgin Islands of the United States of America
+ def self.VI(zipcode)
+ match = zipcode =~ /^([0-9]{5})$/
match == 0 ? true : false
end
# Zambia
def self.ZM(zipcode)
match = zipcode =~ /^([0-9]{5})$/