validates_zipcode 0.3.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b76a1516fa07d400bf8ecab157426a63385b512985468c7e506e5d5150f28570
4
- data.tar.gz: 9bae835a99376edbe35c42e0419cf2dc7aec0cde7d22f6c5c4e4215389c9412c
3
+ metadata.gz: 214ffb965fb27983b44b38dbac18b42041d665e313862b10e809bf3f598c7698
4
+ data.tar.gz: bf2137923c16d09823dfb1fac10c372c2cb0f6f0fbb4c9053b7be5ee38098a2e
5
5
  SHA512:
6
- metadata.gz: bc3619b94ba8b577fd35fa33c5a54b0c229470bc7b173c1408b9a5e552d5cd25ebe141f1445b5694e9576721837984f553b30eeade95485d210d188f5e11e294
7
- data.tar.gz: 64baae1849d7ee97f4d887f5519f9a126ac00a129a47304de21f62790ae8a9c3e1ef9b163336efcd1bbf87d05b75b449be456ee2beacd60ecdeba59e980f8169
6
+ metadata.gz: 40bdbcb70fc0284c0b3f4d1ab3ad626a5f8fe37cd7ef893d5d38ff80961c30bd8736df59752cb4de8367768fa9a57b872a91af09e1376386af33c652b7629cf0
7
+ data.tar.gz: b359270f28b23d87c69f8af0646b7ad0e59140e09bd85b4fadb994b8fce94252c40a32b461f46c3d5fa6b16c806a7fd09c040ab37bbc7491b90b055ccf306edf
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ .dccache
data/.rubocop.yml CHANGED
@@ -12,7 +12,7 @@ require:
12
12
  AllCops:
13
13
  TargetRubyVersion: 2.4
14
14
 
15
- TargetRailsVersion: 4.2
15
+ TargetRailsVersion: 5.2
16
16
 
17
17
  # Include common Ruby source files.
18
18
  Include:
@@ -862,7 +862,7 @@ Layout/DefEndAlignment:
862
862
 
863
863
  ##################### Rails ##################################
864
864
  Rails:
865
- Enabled: true
865
+ Enabled: false
866
866
 
867
867
  Rails/ActionFilter:
868
868
  EnforcedStyle: action
data/.travis.yml CHANGED
@@ -16,14 +16,15 @@ rvm:
16
16
  - 2.4.9
17
17
  - 2.5.7
18
18
  - 2.6.5
19
- - 2.7.0
19
+ - 2.7.2
20
+ - 3.0.0
20
21
  - ruby-head
21
22
  - truffleruby
22
23
 
23
24
  gemfile:
24
25
  - gemfiles/rails_4.2.gemfile
25
26
  - gemfiles/rails_5.2.gemfile
26
- - gemfiles/rails_6.0.gemfile
27
+ - gemfiles/rails_6.1.gemfile
27
28
  - gemfiles/rails_edge.gemfile
28
29
 
29
30
  matrix:
@@ -32,6 +33,8 @@ matrix:
32
33
  - rvm: ruby-head
33
34
  exclude:
34
35
  - rvm: 2.4.9
35
- gemfile: gemfiles/rails_6.gemfile
36
+ gemfile: gemfiles/rails_6.1.gemfile
36
37
  - rvm: 2.4.9
37
38
  gemfile: gemfiles/rails_edge.gemfile
39
+ - rvm: 3.0.0
40
+ gemfile: gemfiles/rails_edge.gemfile
data/Appraisals CHANGED
@@ -8,8 +8,8 @@ appraise 'rails-5.2' do
8
8
  gem 'activemodel', '~> 5.2.0'
9
9
  end
10
10
 
11
- appraise 'rails-6.0' do
12
- gem 'activemodel', '~> 5.2.0'
11
+ appraise 'rails-6.1' do
12
+ gem 'activemodel', '~> 6.1.0'
13
13
  end
14
14
 
15
15
  appraise 'rails_edge' do
data/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 0.5.0
6
+
7
+ - Pass `format: true` option to the `validates_zipcode` or the constructor to attempt for format a given code using the (uncomplete) list of formatters by country. This process will happen before the validation takes place, dealing with case sensitive formats and whitespace, amongst others. This option is false by default for backwards compatibility. ~ @chloe-meister
8
+ - Fixed unconsistent behaviour by which the `ValidatesZipcode.format` and `ValidatesZipcode::Formatter.new(..).format` where formatting an invalid code, the former, and raising a validity error, the latter. ~ @chloe-meister
9
+
10
+ ## 0.4.0
11
+
12
+ **HEADS UP**: While I don't think this update would break any system for anyone, many formats where revisited to make them more loose or strict, potentially rendering your data invalid, particularly in edge cases or with data that was already incorrect in the first place and not flagges as such. I recommend you check your data with the new version in case these validations are critical to you. I am not releasing this as a 1.0 because there are no breaking changes in the API though. See PR #54 for more details.
13
+
14
+ - Many regexps where modified to include recent changes in postal services, fix issues, narrow down formats that where unnecessary broad, allow for some looser cases such as optional whitespaces and making many of them case insensitive and removing countries with no postal codes - See PR #54. Thanks to ~ @ojsdude with some help from @dgilperez
15
+ - Allow the gem to generate test data from the formatters. See README ~ @ojsdude
16
+ - Officially support Ruby 3 and Rails 6.1
17
+
5
18
  ## 0.3.3
6
19
 
7
20
  - Fixes AR regex
data/README.md CHANGED
@@ -82,6 +82,23 @@ ValidatesZipcode.format('Sw1A 2aA', 'FR')
82
82
 
83
83
  At the moment not every country is supported. See [lib/validates_zipcode/formatter.rb](lib/validates_zipcode/formatter.rb) to find all available countries.
84
84
 
85
+ ### Test data
86
+
87
+ In order to generate test data, we suggest using the [regexp-examples gem](https://github.com/tom-lord/regexp-examples)
88
+ This dependency will allow you to create examples as follows:
89
+
90
+ ```ruby
91
+ require "regexp-examples"
92
+
93
+ ValidatesZipcode::CldrRegexpCollection::ZIPCODES_REGEX[:ES].examples
94
+
95
+ # => ["00000", "00001", "00002", "00003", ..., "44443", "44444"]
96
+
97
+ ValidatesZipcode::CldrRegexpCollection::ZIPCODES_REGEX[:ES].random_example
98
+
99
+ # => "27072"
100
+ ```
101
+
85
102
  ## Contributing
86
103
 
87
104
  1. Fork it
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- validates_zipcode (0.3.3)
4
+ validates_zipcode (0.5.0)
5
5
  activemodel (>= 4.2.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- validates_zipcode (0.3.3)
4
+ validates_zipcode (0.5.0)
5
5
  activemodel (>= 4.2.0)
6
6
 
7
7
  GEM
@@ -3,6 +3,6 @@
3
3
 
4
4
  source 'https://rubygems.org'
5
5
 
6
- gem 'activemodel', '~> 5.2.0'
6
+ gem 'activemodel', '~> 6.1.0'
7
7
 
8
8
  gemspec path: '../'
@@ -0,0 +1,85 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ validates_zipcode (0.5.0)
5
+ activemodel (>= 4.2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (6.1.3)
11
+ activesupport (= 6.1.3)
12
+ activesupport (6.1.3)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
+ appraisal (2.4.0)
19
+ bundler
20
+ rake
21
+ thor (>= 0.14.0)
22
+ ast (2.4.2)
23
+ concurrent-ruby (1.1.8)
24
+ diff-lcs (1.4.4)
25
+ i18n (1.8.9)
26
+ concurrent-ruby (~> 1.0)
27
+ minitest (5.14.4)
28
+ parallel (1.20.1)
29
+ parser (3.0.0.0)
30
+ ast (~> 2.4.1)
31
+ rack (2.2.3)
32
+ rainbow (3.0.0)
33
+ rake (13.0.3)
34
+ regexp_parser (2.1.1)
35
+ rexml (3.2.4)
36
+ rspec (3.10.0)
37
+ rspec-core (~> 3.10.0)
38
+ rspec-expectations (~> 3.10.0)
39
+ rspec-mocks (~> 3.10.0)
40
+ rspec-core (3.10.1)
41
+ rspec-support (~> 3.10.0)
42
+ rspec-expectations (3.10.1)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.10.0)
45
+ rspec-mocks (3.10.2)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.10.0)
48
+ rspec-support (3.10.2)
49
+ rubocop (1.11.0)
50
+ parallel (~> 1.10)
51
+ parser (>= 3.0.0.0)
52
+ rainbow (>= 2.2.2, < 4.0)
53
+ regexp_parser (>= 1.8, < 3.0)
54
+ rexml
55
+ rubocop-ast (>= 1.2.0, < 2.0)
56
+ ruby-progressbar (~> 1.7)
57
+ unicode-display_width (>= 1.4.0, < 3.0)
58
+ rubocop-ast (1.4.1)
59
+ parser (>= 2.7.1.5)
60
+ rubocop-rails (2.9.1)
61
+ activesupport (>= 4.2.0)
62
+ rack (>= 1.1)
63
+ rubocop (>= 0.90.0, < 2.0)
64
+ ruby-progressbar (1.11.0)
65
+ thor (1.1.0)
66
+ tzinfo (2.0.4)
67
+ concurrent-ruby (~> 1.0)
68
+ unicode-display_width (2.0.0)
69
+ zeitwerk (2.4.2)
70
+
71
+ PLATFORMS
72
+ ruby
73
+
74
+ DEPENDENCIES
75
+ activemodel (~> 6.1.0)
76
+ appraisal
77
+ bundler
78
+ rake (>= 12.3.3)
79
+ rspec
80
+ rubocop
81
+ rubocop-rails
82
+ validates_zipcode!
83
+
84
+ BUNDLED WITH
85
+ 2.1.4
@@ -14,7 +14,7 @@ GIT
14
14
  PATH
15
15
  remote: ..
16
16
  specs:
17
- validates_zipcode (0.3.3)
17
+ validates_zipcode (0.5.0)
18
18
  activemodel (>= 4.2.0)
19
19
 
20
20
  GEM
@@ -9,9 +9,9 @@ module ValidatesZipcode
9
9
  UK: /\AGIR ?0AA|((([A-Z]\d{1,2})|(([A-Z][A-HJ-Y]\d{1,2})|(([A-Z]\d[A-Z])|([A-Z][A-HJ-Y]\d?[A-Z])))) ?\d[A-Z]{2})\z/i,
10
10
  # GB: /\AGIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\d{1,4}\z/i,
11
11
  # UK: /\A([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)\z/,
12
- JE: /\AJE\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}\z/,
13
- GG: /\AGY\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}\z/,
14
- IM: /\AIM\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}\z/,
12
+ JE: /\AJE\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}\z/i,
13
+ GG: /\AGY\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}\z/i,
14
+ IM: /\AIM\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}\z/i,
15
15
  US: /\A\d{5}([ \-](?:\d{4}|\d{6}))?\z/,
16
16
  IE: /\A([AC-FHKNPRTV-Y]\d{2}|D6W)\s?[0-9AC-FHKNPRTV-Y]{4}\z/,
17
17
  CA: /\A[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ ]?\d[ABCEGHJ-NPRSTV-Z]\d\z/,
@@ -21,7 +21,7 @@ module ValidatesZipcode
21
21
  CH: /\A\d{4}\z/,
22
22
  AT: /\A\d{4}\z/,
23
23
  ES: /\A\d{5}\z/,
24
- NL: /\A[1-9]\d{3}[ ]?(?!SA|SD|SS)[A-Z]{2}\z/,
24
+ NL: /\A[1-9]\d{3}[ ]?(S[BCE-RT-Z]|[A-RT-Z][A-Z])\z/,
25
25
  BE: /\A\d{4}\z/,
26
26
  DK: /\A\d{4}\z/,
27
27
  NO: /\A\d{4}\z/,
@@ -34,13 +34,13 @@ module ValidatesZipcode
34
34
  AD: /\AAD\d{3}\z/,
35
35
  AR: /\A[A-HJ-NP-Z]{1}\d{4}([A-Z]{3})?\z/,
36
36
  AM: /\A(37)?\d{4}\z/,
37
- BH: /\A((1[0-2]|[2-9])\d{2})?\z/,
37
+ BH: /\A(1[0-2]|[1-9])\d{2}\z/,
38
38
  BD: /\A\d{4}\z/,
39
- BB: /\A(BB\d{5})?\z/,
39
+ BB: /\ABB([1-2]\d{4}|15156667)\z/,
40
40
  BY: /\A\d{6}\z/,
41
41
  BM: /\A[A-Z]{2}[ ]?[A-Z0-9]{2}\z/,
42
42
  BA: /\A\d{5}\z/,
43
- BN: /\A[A-Z]{2}[ ]?\d{4}\z/,
43
+ BN: /\A[BKTP][A-Z][ ]?\d{4}\z/i,
44
44
  BG: /\A\d{4}\z/,
45
45
  KH: /\A\d{5}\z/,
46
46
  CV: /\A\d{4}\z/,
@@ -49,7 +49,7 @@ module ValidatesZipcode
49
49
  CY: /\A\d{4}\z/,
50
50
  CZ: /\A[1-7][0-9]{2}[ ]?\d{2}\z/,
51
51
  DO: /\A\d{5}\z/,
52
- EC: /\A([A-Z]\d{4}[A-Z]|(?:[A-Z]{2})?\d{6})?\z/,
52
+ EC: /\A\d{6}\z/,
53
53
  EE: /\A\d{5}\z/,
54
54
  FO: /\A\d{3}\z/,
55
55
  GE: /\A\d{4}\z/,
@@ -60,29 +60,29 @@ module ValidatesZipcode
60
60
  IS: /\A\d{3}\z/,
61
61
  IN: /\A\d{6}\z/,
62
62
  ID: /\A\d{5}\z/,
63
- IL: /\A\d{5,7}\z/,
63
+ IL: /\A(\d{5}|\d{7})\z/,
64
64
  JO: /\A\d{5}\z/,
65
65
  KZ: /\A\d{6}\z/,
66
66
  KE: /\A\d{5}\z/,
67
67
  KW: /\A\d{5}\z/,
68
68
  LA: /\A\d{5}\z/,
69
69
  LB: /\A(\d{4}([ ]?\d{4})?)?\z/,
70
- LU: /\A(L\-)?\d{4}\z/,
70
+ LU: /\A(L[\- ]?)?\d{4}\z/,
71
71
  MK: /\A\d{4}\z/,
72
72
  MY: /\A\d{5}\z/,
73
73
  MV: /\A\d{5}\z/,
74
- MT: /\A[A-Z]{3}[ ]?\d{2,4}\z/,
75
- MU: /\A[ARar1-9]\d{4}\z/,
74
+ MT: /\A[A-Z]{3}[ ]?\d{2,4}\z/i,
75
+ MU: /\A[AR1-9]\d{4}\z/i,
76
76
  MX: /\A\d{5}\z/,
77
77
  MA: /\A\d{5}\z/,
78
78
  NZ: /\A\d{4}\z/,
79
79
  NI: /\A\d{5}\z/,
80
- NG: /\A(\d{6})?\z/,
81
- OM: /\A(PC )?\d{3}\z/,
80
+ NG: /\A\d{6}\z/,
81
+ OM: /\A(PC )?\d{3}\z/i,
82
82
  PK: /\A\d{5}\z/,
83
83
  PY: /\A\d{4}\z/,
84
84
  PH: /\A\d{4}\z/,
85
- PL: /\A\d{2}-\d{3}\z/,
85
+ PL: /\A\d{2}[ -]?\d{3}\z/,
86
86
  PR: /\A00[679]\d{2}([ \-]\d{4})?\z/,
87
87
  RO: /\A\d{6}\z/,
88
88
  RU: /\A\d{6}\z/,
@@ -110,13 +110,13 @@ module ValidatesZipcode
110
110
  YU: /\A\d{5}\z/,
111
111
  CX: /\A6798\z/,
112
112
  ET: /\A\d{4}\z/,
113
- FK: /\AFIQQ 1ZZ\z/,
113
+ FK: /\AFIQQ[ ]?1ZZ\z/i,
114
114
  NF: /\A2899\z/,
115
115
  FM: /\A(9694[1-4])([ \-]\d{4})?\z/,
116
116
  GF: /\A9[78]3\d{2}\z/,
117
117
  GP: /\A9[78][01]\d{2}\z/,
118
- GS: /\ASIQQ 1ZZ\z/,
119
- GU: /\A969[123]\d([ \-]\d{4})?\z/,
118
+ GS: /\ASIQQ[ ]?1ZZ\z/i,
119
+ GU: /\A969[1-3]\d([ \-]\d{4})?\z/,
120
120
  GW: /\A\d{4}\z/,
121
121
  HM: /\A\d{4}\z/,
122
122
  IQ: /\A\d{5}\z/,
@@ -132,117 +132,121 @@ module ValidatesZipcode
132
132
  PF: /\A987\d{2}\z/,
133
133
  PG: /\A\d{3}\z/,
134
134
  PM: /\A9[78]5\d{2}\z/,
135
- PN: /\APCRN 1ZZ\z/,
135
+ PN: /\APCRN[ ]?1ZZ\z/i,
136
136
  PW: /\A96940\z/,
137
- RE: /\A9[78]4\d{2}\z/,
138
- SH: /\A(ASCN|STHL) 1ZZ\z/,
137
+ RE: /\A974\d{2}\z/,
138
+ SH: /\A(ASCN|STHL|TDCU)[ ]?1ZZ\z/i,
139
139
  SJ: /\A\d{4}\z/,
140
- SZ: /\A[HLMS]\d{3}\z/,
141
- TC: /\ATKCA 1ZZ\z/,
140
+ SZ: /\A[HLMS]\d{3}\z/i,
141
+ TC: /\ATKCA[ ]?1ZZ\z/i,
142
142
  WF: /\A986\d{2}\z/,
143
143
  XK: /\A\d{5}\z/,
144
144
  YT: /\A976\d{2}\z/,
145
145
  # NOTE: UAE has no postal codes
146
146
  # https://github.com/dgilperez/validates_zipcode/issues/28
147
- # AE: /\A([a-zA-Z\d\s]){3,}\z/,
147
+ # AE: /\A([A-Z\d\s]){3,}\z/i,
148
148
  AF: /\A\d{4}\z/,
149
149
  AL: /\A\d{4}\z/,
150
- AG: /\A([a-zA-Z\d\s]){3,}\z/,
151
- AO: /\A([a-zA-Z\d\s]){3,}\z/,
152
- AZ: /\A([a-zA-Z\d\s]){3,}\z/,
153
- BF: /\A([a-zA-Z\d\s]){3,}\z/,
154
- BI: /\A([a-zA-Z\d\s]){3,}\z/,
155
- BS: /\A([a-zA-Z\d\s]){3,}\z/,
156
- BZ: /\A([a-zA-Z\d\s]){3,}\z/,
150
+ AG: /\A([A-Z\d\s]){3,}\z/i,
151
+ AO: /\A([A-Z\d\s]){3,}\z/i,
152
+ AZ: /\A(AZ[ ]?)?\d{4}\z/i,
153
+ BF: /\A([A-Z\d\s]){3,}\z/i,
154
+ BI: /\A([A-Z\d\s]){3,}\z/i,
155
+ BS: /\A([A-Z\d\s]){3,}\z/i,
156
+ BZ: /\A([A-Z\d\s]){3,}\z/i,
157
157
  BR: /\A\d{5}(-?\d{3})?\z/,
158
- BJ: /\A([a-zA-Z\d\s]){3,}\z/,
158
+ BJ: /\A([A-Z\d\s]){3,}\z/i,
159
159
  BT: /\A\d{5}\z/,
160
- BQ: /\A([a-zA-Z\d\s]){3,}\z/,
160
+ BQ: /\A([A-Z\d\s]){3,}\z/i,
161
161
  BO: /\A\d{4}\z/,
162
- BW: /\A([a-zA-Z\d\s]){3,}\z/,
163
- CF: /\A([a-zA-Z\d\s]){3,}\z/,
164
- CG: /\A([a-zA-Z\d\s]){3,}\z/,
165
- CI: /\A([a-zA-Z\d\s]){3,}\z/,
166
- CM: /\A([a-zA-Z\d]){3,7}\z/,
167
- CO: /\A([a-zA-Z\d\s]){3,}\z/,
162
+ BW: /\A([A-Z\d\s]){3,}\z/i,
163
+ CF: /\A([A-Z\d\s]){3,}\z/i,
164
+ CG: /\A([A-Z\d\s]){3,}\z/i,
165
+ CI: /\A([A-Z\d\s]){3,}\z/i,
166
+ # NOTE: Cameroon has no postal codes
167
+ # CM: /\A([A-Z\d]){3,7}\z/i,
168
+ CO: /\A([A-Z\d\s]){3,}\z/i,
168
169
  CR: /\A\d{5}\z/,
169
170
  CU: /\A\d{5}\z/,
170
- KM: /\A([a-zA-Z\d\s]){3,}\z/,
171
- DJ: /\A([a-zA-Z\d\s]){3,}\z/,
172
- DM: /\A([a-zA-Z\d\s]){3,}\z/,
173
- EG: /\A([a-zA-Z\d\s]){3,}\z/,
174
- GQ: /\A([a-zA-Z\d\s]){3,}\z/,
171
+ KM: /\A([A-Z\d\s]){3,}\z/i,
172
+ DJ: /\A([A-Z\d\s]){3,}\z/i,
173
+ DM: /\A([A-Z\d\s]){3,}\z/i,
174
+ EG: /\A([A-Z\d\s]){3,}\z/i,
175
+ GQ: /\A([A-Z\d\s]){3,}\z/i,
175
176
  EL: /\A\d{5}\z/,
176
- ER: /\A([a-zA-Z\d\s]){3,}\z/,
177
- FJ: /\A([a-zA-Z\d\s]){3,}\z/,
177
+ ER: /\A([A-Z\d\s]){3,}\z/i,
178
+ FJ: /\A([A-Z\d\s]){3,}\z/i,
178
179
  FR: /\A\d{5}\z/,
179
- GA: /\A\d{2}\z/,
180
- GD: /\A([a-zA-Z\d\s]){3,}\z/,
181
- GH: /\A([a-zA-Z\d\s]){3,}\z/,
182
- GM: /\A([a-zA-Z\d\s]){3,}\z/,
183
- GN: /\A([a-zA-Z\d\s]){3,}\z/,
184
- GI: /\A(GX11 1AA)\z/,
180
+ GA: /\A\d{4}\z/,
181
+ GD: /\A([A-Z\d\s]){3,}\z/i,
182
+ GH: /\A([A-Z\d\s]){3,}\z/i,
183
+ GM: /\A([A-Z\d\s]){3,}\z/i,
184
+ GN: /\A([A-Z\d\s]){3,}\z/i,
185
+ GI: /\A(GX11[ ]?1AA)\z/i,
185
186
  GR: /\A\d{3}[ ]?\d{2}\z/,
186
- GY: /\A([a-zA-Z\d\s]){3,}\z/,
187
- HN: /\A(([a-zA-Z]){2}|\d{2})\d{4}\z/,
187
+ GY: /\A([A-Z\d\s]){3,}\z/i,
188
+ HN: /\A(([A-Z]){2}|\d{2})\d{4}\z/i,
188
189
  IO: /\A\d{5}\z/,
189
190
  IR: /\A\d{5}\z/,
190
191
  JP: /\A\d{3}\-?\d{4}\z/,
191
- JM: /\A(JM)[A-Z]{3}\d{2}\z/,
192
- KI: /\A([a-zA-Z\d\s]){3,}\z/,
193
- KN: /\A([a-zA-Z\d\s]){3,8}\z/,
194
- KP: /\A([a-zA-Z\d\s]){3,8}\z/,
192
+ # Jamaica has no postcode system.However, for Kingston, there are one- and two-digit sector codes.
193
+ # On February 12, 2007 it was announced: "POST CODE PROJECT SUSPENDED INDEFINITELY"
194
+ # https://en.youbianku.com/Jamaica#:~:text=Jamaica%20has%20no%20postcode%20system,the%20name%20of%20the%20town.
195
+ JM: /\A((JM(DCN|CHR|AKN|DMR|BPD|AAW|CAN|ACE|DEH|CJS|BMY|BTS|CTY|DWD)(0[1-9]|[1-2]\d))|\d{1,2})?\z/i,
196
+ KI: /\AKI0[1-3]\d{2}\z/i,
197
+ KN: /\AKN[ ]?\d{4}\z/i,
198
+ KP: /\A([A-Z\d\s]){3,8}\z/i,
195
199
  LI: /\A\d{4}\z/,
196
- LV: /\A(LV)?\-?\d{4}\z/,
200
+ LV: /\A(LV[\- ]?)?\d{4}\z/i,
197
201
  LY: /\A\d{5}\z/,
198
- LT: /\A(LT-)?\d{5}\z/,
199
- LC: /\A([a-zA-Z\d\s]){3,}\z/,
202
+ LT: /\A(LT[\- ]?)?\d{5}\z/i,
203
+ LC: /\A([A-Z\d\s]){3,}\z/i,
200
204
  MC: /\A\d{5}\z/,
201
- MD: /\A(([a-zA-Z]){2})(|\s)\d{4}\z/,
202
- ME: /\A([a-zA-Z\d\s]){3,}\z/,
205
+ MD: /\A(([A-Z]){2})(|\s)\d{4}\z/i,
206
+ ME: /\A([A-Z\d\s]){3,}\z/i,
203
207
  MH: /\A\d{5}\z/,
204
- MR: /\A([a-zA-Z\d\s]){3,}\z/,
205
- MM: /\A([a-zA-Z\d\s]){3,}\z/,
206
- MW: /\A([a-zA-Z\d\s]){3,}\z/,
208
+ MR: /\A([A-Z\d\s]){3,}\z/i,
209
+ MM: /\A([A-Z\d\s]){3,}\z/i,
210
+ MW: /\A([A-Z\d\s]){3,}\z/i,
207
211
  MZ: /\A\d{4}\z/,
208
212
  NA: /\A\d{5}\z/,
209
213
  NP: /\A\d{6}\z/,
210
- NR: /\A([a-zA-Z\d\s]){3,}\z/,
214
+ NR: /\A([A-Z\d\s]){3,}\z/i,
211
215
  PT: /\A\d{4}([\-]\d{3})?\z/,
212
216
  PS: /\A\d{3}\z/,
213
217
  PA: /\A\d{4}\z/,
214
218
  PE: /\A\d{5}\z/,
215
- QA: /\A([a-zA-Z\d\s]){3,}\z/,
216
- RW: /\A([a-zA-Z\d\s]){3,}\z/,
217
- SC: /\A([a-zA-Z\d\s]){3,}\z/,
219
+ QA: /\A([A-Z\d\s]){3,}\z/i,
220
+ RW: /\A([A-Z\d\s]){3,}\z/i,
221
+ SC: /\A([A-Z\d\s]){3,}\z/i,
218
222
  SE: /\A\d{3}[ ]?\d{2}\z/,
219
223
  SK: /\A[089]\d{2}[ ]?\d{2}\z/,
220
- SL: /\A([a-zA-Z\d\s]){3,}\z/,
221
- SB: /\A([a-zA-Z\d\s]){3,}\z/,
222
- SR: /\A([a-zA-Z\d\s]){3,}\z/,
223
- SO: /\A([a-zA-Z\d\s]){3,}\z/,
224
- SV: /\A([a-zA-Z\d\s]){3,}\z/,
224
+ SL: /\A([A-Z\d\s]){3,}\z/i,
225
+ SB: /\A([A-Z\d\s]){3,}\z/i,
226
+ SR: /\A([A-Z\d\s]){3,}\z/i,
227
+ SO: /\A([A-Z\d\s]){3,}\z/i,
228
+ SV: /\A([A-Z\d\s]){3,}\z/i,
225
229
  SD: /\A\d{5}\z/,
226
- ST: /\A([a-zA-Z\d\s]){3,}\z/,
227
- SY: /\A([a-zA-Z\d\s]){3,}\z/,
230
+ ST: /\A([A-Z\d\s]){3,}\z/i,
231
+ SY: /\A([A-Z\d\s]){3,}\z/i,
228
232
  SS: /\A\d{5}\z/,
229
233
  TD: /\A\d{5}\z/,
230
- TG: /\A([a-zA-Z\d\s]){3,}\z/,
231
- TO: /\A([a-zA-Z\d\s]){3,}\z/,
232
- TZ: /\A([a-zA-Z\d\s]){3,}\z/,
234
+ TG: /\A([A-Z\d\s]){3,}\z/i,
235
+ TO: /\A([A-Z\d\s]){3,}\z/i,
236
+ TZ: /\A([A-Z\d\s]){3,}\z/i,
233
237
  TT: /\A\d{6}\z/,
234
238
  TW: /\A\d{3}(\d{2})?\z/,
235
- UG: /\A([a-zA-Z\d\s]){3,}\z/,
236
- UM: /\A([a-zA-Z\d\s]){3,}\z/,
237
- UY: /\A([a-zA-Z\d\s]){3,}\z/,
238
- VC: /\A(VC)\d{4}\z/,
239
+ UG: /\A([A-Z\d\s]){3,}\z/i,
240
+ UM: /\A([A-Z\d\s]){3,}\z/i,
241
+ UY: /\A([A-Z\d\s]){3,}\z/i,
242
+ VC: /\A(VC)\d{4}\z/i,
239
243
  VI: /\A\d{5}\z/,
240
- VG: /\A([a-zA-Z\d\s]){3,}\z/,
244
+ VG: /\A([A-Z\d\s]){3,}\z/i,
241
245
  VN: /\A\d{6}\z/,
242
- VU: /\A([a-zA-Z\d\s]){3,}\z/,
243
- WS: /\A([a-zA-Z\d\s]){3,}\z/,
244
- YE: /\A([a-zA-Z\d\s]){3,}\z/,
245
- ZW: /\A([a-zA-Z\d\s]){3,}\z/
246
+ VU: /\A([A-Z\d\s]){3,}\z/i,
247
+ WS: /\A([A-Z\d\s]){3,}\z/i,
248
+ YE: /\A([A-Z\d\s]){3,}\z/i,
249
+ ZW: /\A([A-Z\d\s]){3,}\z/i
246
250
  }.freeze
247
251
 
248
252
  def regexp_for_country_alpha2(alpha2)