lib/validate_zipcode/regex.rb in validate_zipcode-1.1.1 vs lib/validate_zipcode/regex.rb in validate_zipcode-1.2.0

- old
+ new

@@ -1,43 +1,254 @@ module ValidateZipcode module Regex - def self.US(zipcode) - match = zipcode =~ /^([0-9]{5})$|([0-9]{9})$|([0-9]{5}-[0-9]{4})$/ + # Algeria + def self.DZ(zipcode) + match = zipcode =~ /^([0-9]{5})$/ match == 0 ? true : false end - + # Australia + def self.AU(zipcode) + match = zipcode =~ /^([0-9]{4})$/ + match == 0 ? true : false + end + # Austria + def self.AT(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 + # Brazil def self.BR(zipcode) match = zipcode =~ /^([0-9]{5}-[0-9]{3})$|([0-9]{8})$/ match == 0 ? true : false end - - def self.FR(zipcode) + # Bulgaria + def self.BG(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 + # Chile + def self.CL(zipcode) + match = zipcode =~ /^([0-9]{3}-[0-9]{4})$|([0-9]{7})$/ + match == 0 ? true : false + end + # China + def self.CN(zipcode) + match = zipcode =~ /^([0-9]{6})$/ + match == 0 ? true : false + end + # Colombia + def self.CO(zipcode) + match = zipcode =~ /^([0-9]{6})$/ + match == 0 ? true : false + end + # Croatia + def self.HR(zipcode) match = zipcode =~ /^([0-9]{5})$/ match == 0 ? true : false end - - def self.IT(zipcode) + # Cuba + def self.CU(zipcode) match = zipcode =~ /^([0-9]{5})$/ match == 0 ? true : false end - + # Denmark + def self.DK(zipcode) + match = zipcode =~ /^([0-9]{4})$/ + match == 0 ? true : false + end + # Deutsch or Germany def self.DE(zipcode) match = zipcode =~ /^([0-9]{5})$/ match == 0 ? true : false end - - def self.ES(zipcode) + # Estonia + def self.EE(zipcode) match = zipcode =~ /^([0-9]{5})$/ match == 0 ? true : false end - - def self.CN(zipcode) + # Ethiopia + def self.ET(zipcode) + match = zipcode =~ /^([0-9]{4})$/ + match == 0 ? true : false + end + # Finland + def self.FI(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + match == 0 ? true : false + end + # France + def self.FR(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + 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 + # India + def self.IN(zipcode) match = zipcode =~ /^([0-9]{6})$/ match == 0 ? true : false end - + # Indonesia + def self.ID(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + match == 0 ? true : false + end + # Iraq + def self.IQ(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + match == 0 ? true : false + end + # Israel + def self.IL(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + match == 0 ? true : false + end + # Italy + def self.IT(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + match == 0 ? true : false + end + # Japan def self.JP(zipcode) match = zipcode =~ /^([0-9]{3}-[0-9]{4})$|([0-9]{7})$/ + match == 0 ? true : false + end + # Kazakhstan + def self.KZ(zipcode) + match = zipcode =~ /^([0-9]{6})$/ + 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 + # 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 + # Portugal + def self.PT(zipcode) + match = zipcode =~ /^([0-9]{4}-[0-9]{3})$|([0-9]{7})$/ + match == 0 ? true : false + end + # Romania + def self.RO(zipcode) + match = zipcode =~ /^([0-9]{6})$/ + match == 0 ? true : false + end + # Russian + def self.RU(zipcode) + match = zipcode =~ /^([0-9]{6})$/ + match == 0 ? true : false + end + # Saudi Arabia + def self.SA(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + match == 0 ? true : false + end + # Senegal + def self.SN(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + match == 0 ? true : false + end + # Singapore + def self.SG(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + match == 0 ? true : false + end + # Slovenia + def self.SI(zipcode) + match = zipcode =~ /^([0-9]{4})$/ + match == 0 ? true : false + end + # South Africa + def self.ZA(zipcode) + match = zipcode =~ /^([0-9]{4})$/ + match == 0 ? true : false + end + # Spain + def self.ES(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + match == 0 ? true : false + end + # Sri Lanka + def self.LK(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + 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 + # Tunisia + def self.TN(zipcode) + match = zipcode =~ /^([0-9]{4})$/ + match == 0 ? true : false + end + # Turkey + def self.TR(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + match == 0 ? true : false + end + # Turkmenistan + def self.TM(zipcode) + match = zipcode =~ /^([0-9]{6})$/ + match == 0 ? true : false + end + # Ukraine + def self.UA(zipcode) + match = zipcode =~ /^([0-9]{5})$/ + match == 0 ? true : false + end + # United Stade + def self.US(zipcode) + match = zipcode =~ /^([0-9]{5})$|([0-9]{9})$|([0-9]{5}-[0-9]{4})$/ + match == 0 ? true : false + end + # Uzbekistan + def self.UZ(zipcode) + match = zipcode =~ /^([0-9]{6})$/ + match == 0 ? true : false + end + # Venezuela + def self.VE(zipcode) + match = zipcode =~ /^([0-9]{4})$/ + match == 0 ? true : false + end + # Zambia + def self.ZM(zipcode) + match = zipcode =~ /^([0-9]{5})$/ match == 0 ? true : false end end end