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6})?\z/,
  EE: /\A\d{5}\z/,
  FO: /\A\d{3}\z/,
  GE: /\A\d{4}\z/,
  GL: /\A39\d{2}\z/,
  GT: /\A\d{5}\z/,
  HT: /\A\d{4}\z/,
  HU: /\A\d{4}\z/,
  IS: /\A\d{3}\z/,
  IN: /\A\d{6}\z/,
  ID: /\A\d{5}\z/,
  IL: /\A\d{5,7}\z/,
  JO: /\A\d{5}\z/,
  KZ: /\A\d{6}\z/,
  KE: /\A\d{5}\z/,
  KW: /\A\d{5}\z/,
  LA: /\A\d{5}\z/,
  LB: /\A(\d{4}([ ]?\d{4})?)?\z/,
  LU: /\A(L\-)?\d{4}\z/,
  MK: /\A\d{4}\z/,
  MY: /\A\d{5}\z/,
  MV: /\A\d{5}\z/,
  MT: /\A[A-Z]{3}[ ]?\d{2,4}\z/,
  MU: /\A[ARar1-9]\d{4}\z/,
  MX: /\A\d{5}\z/,
  MA: /\A\d{5}\z/,
  NZ: /\A\d{4}\z/,
  NI: /\A\d{5}\z/,
  NG: /\A(\d{6})?\z/,
  OM: /\A(PC )?\d{3}\z/,
  PK: /\A\d{5}\z/,
  PY: /\A\d{4}\z/,
  PH: /\A\d{4}\z/,
  PL: /\A\d{2}-\d{3}\z/,
  PR: /\A00[679]\d{2}([ \-]\d{4})?\z/,
  RO: /\A\d{6}\z/,
  RU: /\A\d{6}\z/,
  SM: /\A4789\d\z/,
  SA: /\A\d{5}\z/,
  SN: /\A\d{5}\z/,
  SI: /\A\d{4}\z/,
  ZA: /\A\d{4}\z/,
  LK: /\A\d{5}\z/,
  TJ: /\A\d{6}\z/,
  TH: /\A\d{5}\z/,
  TN: /\A\d{4}\z/,
  TR: /\A\d{5}\z/,
  TM: /\A\d{6}\z/,
  UA: /\A\d{5}\z/,
  UZ: /\A\d{6}\z/,
  VA: /\A00120\z/,
  VE: /\A\d{4}\z/,
  ZM: /\A\d{5}\z/,
  AS: /\A96799\z/,
  CC: /\A6799\z/,
  CK: /\A\d{4}\z/,
  RS: /\A\d{5}\z/,
  CS: /\A\d{5}\z/,
  YU: /\A\d{5}\z/,
  CX: /\A6798\z/,
  ET: /\A\d{4}\z/,
  FK: /\AFIQQ 1ZZ\z/,
  NF: /\A2899\z/,
  FM: /\A(9694[1-4])([ \-]\d{4})?\z/,
  GF: /\A9[78]3\d{2}\z/,
  GP: /\A9[78][01]\d{2}\z/,
  GS: /\ASIQQ 1ZZ\z/,
  GU: /\A969[123]\d([ \-]\d{4})?\z/,
  GW: /\A\d{4}\z/,
  HM: /\A\d{4}\z/,
  IQ: /\A\d{5}\z/,
  KG: /\A\d{6}\z/,
  LR: /\A\d{4}\z/,
  LS: /\A\d{3}\z/,
  MG: /\A\d{3}\z/,
  MN: /\A\d{6}\z/,
  MP: /\A9695[012]([ \-]\d{4})?\z/,
  MQ: /\A9[78]2\d{2}\z/,
  NC: /\A988\d{2}\z/,
  NE: /\A\d{4}\z/,
  PF: /\A987\d{2}\z/,
  PG: /\A\d{3}\z/,
  PM: /\A9[78]5\d{2}\z/,
  PN: /\APCRN 1ZZ\z/,
  PW: /\A96940\z/,
  RE: /\A9[78]4\d{2}\z/,
  SH: /\A(ASCN|STHL) 1ZZ\z/,
  SJ: /\A\d{4}\z/,
  SZ: /\A[HLMS]\d{3}\z/,
  TC: /\ATKCA 1ZZ\z/,
  WF: /\A986\d{2}\z/,
  XK: /\A\d{5}\z/,
  YT: /\A976\d{2}\z/,
  # NOTE: UAE has no postal codes
  # https://github.com/dgilperez/validates_zipcode/issues/28
  # AE: /\A([a-zA-Z\d\s]){3,}\z/,
  AF: /\A\d{4}\z/,
  AL: /\A\d{4}\z/,
  AG: /\A([a-zA-Z\d\s]){3,}\z/,
  AO: /\A([a-zA-Z\d\s]){3,}\z/,
  AZ: /\A([a-zA-Z\d\s]){3,}\z/,
  BF: /\A([a-zA-Z\d\s]){3,}\z/,
  BI: /\A([a-zA-Z\d\s]){3,}\z/,
  BS: /\A([a-zA-Z\d\s]){3,}\z/,
  BZ: /\A([a-zA-Z\d\s]){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LV)?\-?\d{4}\z/,
  LY: /\A\d{5}\z/,
  LT: /\A(LT-)?\d{5}\z/,
  LC: /\A([a-zA-Z\d\s]){3,}\z/,
  MC: /\A\d{5}\z/,
  MD: /\A(([a-zA-Z]){2})(|\s)\d{4}\z/,
  ME: /\A([a-zA-Z\d\s]){3,}\z/,
  MH: /\A\d{5}\z/,
  MR: /\A([a-zA-Z\d\s]){3,}\z/,
  MM: /\A([a-zA-Z\d\s]){3,}\z/,
  MW: /\A([a-zA-Z\d\s]){3,}\z/,
  MZ: /\A\d{4}\z/,
  NA: /\A\d{5}\z/,
  NP: /\A\d{6}\z/,
  NR: /\A([a-zA-Z\d\s]){3,}\z/,
  PT: /\A\d{4}([\-]\d{3})?\z/,
  PS: /\A\d{3}\z/,
  PA: /\A\d{4}\z/,
  PE: /\A\d{5}\z/,
  QA: /\A([a-zA-Z\d\s]){3,}\z/,
  RW: /\A([a-zA-Z\d\s]){3,}\z/,
  SC: /\A([a-zA-Z\d\s]){3,}\z/,
  SE: /\A\d{3}[ ]?\d{2}\z/,
  SK: /\A[089]\d{2}[ ]?\d{2}\z/,
  SL: /\A([a-zA-Z\d\s]){3,}\z/,
  SB: /\A([a-zA-Z\d\s]){3,}\z/,
  SR: /\A([a-zA-Z\d\s]){3,}\z/,
  SO: /\A([a-zA-Z\d\s]){3,}\z/,
  SV: /\A([a-zA-Z\d\s]){3,}\z/,
  SD: /\A\d{5}\z/,
  ST: /\A([a-zA-Z\d\s]){3,}\z/,
  SY: /\A([a-zA-Z\d\s]){3,}\z/,
  SS: /\A\d{5}\z/,
  TD: /\A\d{5}\z/,
  TG: /\A([a-zA-Z\d\s]){3,}\z/,
  TO: /\A([a-zA-Z\d\s]){3,}\z/,
  TZ: /\A([a-zA-Z\d\s]){3,}\z/,
  TT: /\A\d{6}\z/,
  TW: /\A\d{3}(\d{2})?\z/,
  UG: /\A([a-zA-Z\d\s]){3,}\z/,
  UM: /\A([a-zA-Z\d\s]){3,}\z/,
  UY: /\A([a-zA-Z\d\s]){3,}\z/,
  VC: /\A(VC)\d{4}\z/,
  VI: /\A\d{5}\z/,
  VG: /\A([a-zA-Z\d\s]){3,}\z/,
  VN: /\A\d{6}\z/,
  VU: /\A([a-zA-Z\d\s]){3,}\z/,
  WS: /\A([a-zA-Z\d\s]){3,}\z/,
  YE: /\A([a-zA-Z\d\s]){3,}\z/,
  ZW: /\A([a-zA-Z\d\s]){3,}\z/
}.freeze

Instance Method Summary collapse

Instance Method Details

#regexp_for_country_alpha2(alpha2) ⇒ Object



249
250
251
252
253
# File 'lib/validates_zipcode/cldr_regex_collection.rb', line 249

def regexp_for_country_alpha2(alpha2)
  alpha2 = alpha2.to_s.upcase.to_sym

  ZIPCODES_REGEX[alpha2]
end