validates_zipcode 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Appraisals CHANGED
@@ -1,19 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise 'rails-4.2' do
4
- gem 'activemodel', '~> 4.2.0'
3
+ appraise 'rails-8.0' do
4
+ gem 'activemodel', '~> 8.0.0'
5
5
  end
6
6
 
7
- appraise 'rails-5.2' do
8
- gem 'activemodel', '~> 5.2.0'
9
- end
10
-
11
- appraise 'rails-6.1' do
12
- gem 'activemodel', '~> 6.1.0'
13
- end
14
-
15
- appraise 'rails-7.0' do
16
- gem 'activemodel', '~> 7.0.0'
7
+ appraise 'rails-8.1' do
8
+ gem 'activemodel', '~> 8.1.0'
17
9
  end
18
10
 
19
11
  appraise 'rails_edge' do
data/CHANGELOG.md CHANGED
@@ -4,10 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## Unreleased
6
6
 
7
- ## 0.6.1
7
+ ## 0.7.0
8
8
 
9
- Backport of the postcode fixes in 0.7.0 for apps that cannot move to Ruby >= 3.3 and Rails >= 8.0 yet. Requirements are unchanged from 0.6.0.
9
+ **Heads up:** This release requires Ruby >= 3.3 and ActiveModel >= 8.0, the versions that still receive security fixes. Apps on older Ruby or Rails should stay on 0.6.x.
10
10
 
11
+ - Drop support for end-of-life Ruby (< 3.3) and Rails (< 8.0); test on Ruby 3.3, 3.4 and 4.0 with Rails 8.0, 8.1 and main
12
+ - Replace the defunct Travis CI setup with GitHub Actions
11
13
  - Accept Nigeria's (NG) 11-character digital postcode, such as `EK-01-A03-FK-01`, alongside the six-digit code. NIPOST launched it in October 2026. Thanks to ~ @Adeniyikayodee
12
14
  - Fix the Moldova (MD) postcode pattern: accept the canonical `MD-####` form and bare 4-digit codes, and reject non-`MD` letter prefixes. The previous pattern required any two letters and rejected the hyphenated form — fixes #73
13
15
 
data/Gemfile CHANGED
@@ -4,3 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in validates_zipcode.gemspec
6
6
  gemspec
7
+
8
+ gem 'appraisal'
9
+ gem 'rake', '>= 13.0'
10
+ gem 'rspec'
11
+ gem 'rubocop'
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # ValidatesZipcode [![Build Status](https://secure.travis-ci.org/dgilperez/validates_zipcode.png)](https://travis-ci.org/dgilperez/validates_zipcode) [![Code Climate](https://codeclimate.com/github/dgilperez/validates_zipcode/badges/gpa.svg)](https://codeclimate.com/github/dgilperez/validates_zipcode) [![Gem Version](https://badge.fury.io/rb/validates_zipcode.svg)](http://badge.fury.io/rb/validates_zipcode) [![security](https://hakiri.io/github/dgilperez/validates_zipcode/master.svg)](https://hakiri.io/github/dgilperez/validates_zipcode/master)
1
+ # ValidatesZipcode [![CI](https://github.com/dgilperez/validates_zipcode/actions/workflows/ci.yml/badge.svg)](https://github.com/dgilperez/validates_zipcode/actions/workflows/ci.yml) [![Gem Version](https://badge.fury.io/rb/validates_zipcode.svg)](https://badge.fury.io/rb/validates_zipcode)
2
2
 
3
3
  Adds zipcode / postal code validation support to Rails (ActiveModel), considering postal code formats for mostly every country.
4
4
 
5
5
  ``ValidatesZipcode`` currently support **233 country codes**. Regex data taken from several sources, being the main source the [CLDR](http://unicode.org/cldr/trac/browser/tags/release-27-d05/common/supplemental/postalCodeData.xml) database (release 27, around 159). Any other country's postal code will validate without errors.
6
6
 
7
- ``ValidatesZipcode`` supports Rails >= 4.2 and Ruby >= 2.4. This gem could work in Rails 3.2 and Ruby 1.9.3 as well, yet unsupported; try v0.2 series if having trouble with later versions. Truffleruby is also tested, but no reports of working in production apps for now.
7
+ ``ValidatesZipcode`` supports the Ruby and Rails versions that still receive security fixes: Ruby >= 3.3 and Rails (ActiveModel) >= 8.0. For older versions, use the v0.6 series (Rails >= 4.2, Ruby >= 2.4) or the v0.2 series (Rails 3.2, Ruby 1.9.3).
8
8
 
9
9
  ## Installation
10
10
 
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake", ">= 13.0"
7
+ gem "rspec"
8
+ gem "rubocop"
9
+ gem "activemodel", "~> 8.0.0"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake", ">= 13.0"
7
+ gem "rspec"
8
+ gem "rubocop"
9
+ gem "activemodel", "~> 8.1.0"
10
+
11
+ gemspec path: "../"
@@ -2,6 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ gem "appraisal"
6
+ gem "rake", ">= 13.0"
7
+ gem "rspec"
8
+ gem "rubocop"
5
9
  gem "activemodel", github: "rails/rails"
6
10
 
7
11
  gemspec path: "../"
@@ -9,25 +9,25 @@ 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/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
- US: /\A\d{5}([ \-](?:\d{4}|\d{6}))?\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
+ 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
- CA: /\A[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ ]?\d[ABCEGHJ-NPRSTV-Z]\d\z/,
17
+ CA: /\A[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z] ?\d[ABCEGHJ-NPRSTV-Z]\d\z/,
18
18
  DE: /\A\d{5}\z/,
19
19
  AU: /\A\d{4}\z/,
20
20
  IT: /\A\d{5}\z/,
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}[ ]?(S[BCE-RT-Z]|[A-RT-Z][A-Z])\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/,
28
28
  FI: /\A\d{5}\z/,
29
29
  AX: /\A22\d{3}\z/,
30
- KR: /\A(\d{5}|\d{3}[\-]\d{3})\z/,
30
+ KR: /\A(\d{5}|\d{3}-\d{3})\z/,
31
31
  CN: /\A\d{6}\z/,
32
32
  SG: /\A\d{6}\z/,
33
33
  DZ: /\A\d{5}\z/,
@@ -38,16 +38,16 @@ module ValidatesZipcode
38
38
  BD: /\A\d{4}\z/,
39
39
  BB: /\ABB([1-2]\d{4}|15156667)\z/,
40
40
  BY: /\A\d{6}\z/,
41
- BM: /\A[A-Z]{2}[ ]?[A-Z0-9]{2}\z/,
41
+ BM: /\A[A-Z]{2} ?[A-Z0-9]{2}\z/,
42
42
  BA: /\A\d{5}\z/,
43
- BN: /\A[BKTP][A-Z][ ]?\d{4}\z/i,
43
+ BN: /\A[BKTP][A-Z] ?\d{4}\z/i,
44
44
  BG: /\A\d{4}\z/,
45
45
  KH: /\A\d{6}\z/,
46
46
  CV: /\A\d{4}\z/,
47
- CL: /\A\d{3}[-]?\d{4}\z/,
47
+ CL: /\A\d{3}-?\d{4}\z/,
48
48
  HR: /\A\d{5}\z/,
49
49
  CY: /\A\d{4}\z/,
50
- CZ: /\A[1-7][0-9]{2}[ ]?\d{2}\z/,
50
+ CZ: /\A[1-7][0-9]{2} ?\d{2}\z/,
51
51
  DO: /\A\d{5}\z/,
52
52
  EC: /\A\d{6}\z/,
53
53
  EE: /\A\d{5}\z/,
@@ -66,12 +66,12 @@ module ValidatesZipcode
66
66
  KE: /\A\d{5}\z/,
67
67
  KW: /\A\d{5}\z/,
68
68
  LA: /\A\d{5}\z/,
69
- LB: /\A(\d{4}([ ]?\d{4})?)?\z/,
70
- LU: /\A(L[\- ]?)?\d{4}\z/,
69
+ LB: /\A(\d{4}( ?\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/i,
74
+ MT: /\A[A-Z]{3} ?\d{2,4}\z/i,
75
75
  MU: /\A[AR1-9]\d{4}\z/i,
76
76
  MX: /\A\d{5}\z/,
77
77
  MA: /\A\d{5}\z/,
@@ -83,7 +83,7 @@ module ValidatesZipcode
83
83
  PY: /\A(\d{4}|\d{6})\z/,
84
84
  PH: /\A\d{4}\z/,
85
85
  PL: /\A\d{2}[ -]?\d{3}\z/,
86
- PR: /\A00[679]\d{2}([ \-]\d{4})?\z/,
86
+ PR: /\A00[679]\d{2}([ -]\d{4})?\z/,
87
87
  RO: /\A\d{6}\z/,
88
88
  RU: /\A\d{6}\z/,
89
89
  SM: /\A4789\d\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/i,
113
+ FK: /\AFIQQ ?1ZZ\z/i,
114
114
  NF: /\A2899\z/,
115
- FM: /\A(9694[1-4])([ \-]\d{4})?\z/,
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/i,
119
- GU: /\A969[1-3]\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/,
@@ -125,20 +125,20 @@ module ValidatesZipcode
125
125
  LS: /\A\d{3}\z/,
126
126
  MG: /\A\d{3}\z/,
127
127
  MN: /\A\d{5}(-?\d{4})?\z/,
128
- MP: /\A9695[012]([ \-]\d{4})?\z/,
128
+ MP: /\A9695[012]([ -]\d{4})?\z/,
129
129
  MQ: /\A9[78]2\d{2}\z/,
130
130
  NC: /\A988\d{2}\z/,
131
131
  NE: /\A\d{4}\z/,
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/i,
135
+ PN: /\APCRN ?1ZZ\z/i,
136
136
  PW: /\A96940\z/,
137
137
  RE: /\A974\d{2}\z/,
138
- SH: /\A(ASCN|STHL|TDCU)[ ]?1ZZ\z/i,
138
+ SH: /\A(ASCN|STHL|TDCU) ?1ZZ\z/i,
139
139
  SJ: /\A\d{4}\z/,
140
140
  SZ: /\A[HLMS]\d{3}\z/i,
141
- TC: /\ATKCA[ ]?1ZZ\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/,
@@ -149,7 +149,7 @@ module ValidatesZipcode
149
149
  AL: /\A\d{4}\z/,
150
150
  AG: /\A([A-Z\d\s]){3,}\z/i,
151
151
  AO: /\A([A-Z\d\s]){3,}\z/i,
152
- AZ: /\A(AZ[ ]?)?\d{4}\z/i,
152
+ AZ: /\A(AZ ?)?\d{4}\z/i,
153
153
  BF: /\A([A-Z\d\s]){3,}\z/i,
154
154
  BI: /\A([A-Z\d\s]){3,}\z/i,
155
155
  BS: /\A([A-Z\d\s]){3,}\z/i,
@@ -183,24 +183,24 @@ module ValidatesZipcode
183
183
  GH: /\A([A-Z\d\s]){3,}\z/i,
184
184
  GM: /\A([A-Z\d\s]){3,}\z/i,
185
185
  GN: /\A([A-Z\d\s]){3,}\z/i,
186
- GI: /\A(GX11[ ]?1AA)\z/i,
187
- GR: /\A\d{3}[ ]?\d{2}\z/,
186
+ GI: /\A(GX11 ?1AA)\z/i,
187
+ GR: /\A\d{3} ?\d{2}\z/,
188
188
  GY: /\A([A-Z\d\s]){3,}\z/i,
189
189
  HN: /\A([A-Z]{2}|\d{1})\d{4}\z/i,
190
190
  IO: /\A\d{5}\z/,
191
191
  IR: /\A\d{5}\z/,
192
- JP: /\A\d{3}\-?\d{4}\z/,
192
+ JP: /\A\d{3}-?\d{4}\z/,
193
193
  # Jamaica has no postcode system.However, for Kingston, there are one- and two-digit sector codes.
194
194
  # On February 12, 2007 it was announced: "POST CODE PROJECT SUSPENDED INDEFINITELY"
195
195
  # https://en.youbianku.com/Jamaica#:~:text=Jamaica%20has%20no%20postcode%20system,the%20name%20of%20the%20town.
196
196
  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,
197
197
  KI: /\AKI0[1-3]\d{2}\z/i,
198
- KN: /\AKN[ ]?\d{4}\z/i,
198
+ KN: /\AKN ?\d{4}\z/i,
199
199
  KP: /\A([A-Z\d\s]){3,8}\z/i,
200
200
  LI: /\A\d{4}\z/,
201
- LV: /\A(LV[\- ]?)?\d{4}\z/i,
201
+ LV: /\A(LV[- ]?)?\d{4}\z/i,
202
202
  LY: /\A\d{5}\z/,
203
- LT: /\A(LT[\- ]?)?\d{5}\z/i,
203
+ LT: /\A(LT[- ]?)?\d{5}\z/i,
204
204
  LC: /\A([A-Z\d\s]){3,}\z/i,
205
205
  MC: /\A\d{5}\z/,
206
206
  MD: /\A(MD[- ]?)?\d{4}\z/i,
@@ -213,15 +213,15 @@ module ValidatesZipcode
213
213
  NA: /\A\d{5}\z/,
214
214
  NP: /\A\d{5}\z/,
215
215
  NR: /\A([A-Z\d\s]){3,}\z/i,
216
- PT: /\A\d{4}([\-]\d{3})?\z/,
216
+ PT: /\A\d{4}(-\d{3})?\z/,
217
217
  PS: /\A\d{3}\z/,
218
218
  PA: /\A\d{4}\z/,
219
219
  PE: /\A\d{5}\z/,
220
220
  QA: /\A([A-Z\d\s]){3,}\z/i,
221
221
  RW: /\A([A-Z\d\s]){3,}\z/i,
222
222
  SC: /\A([A-Z\d\s]){3,}\z/i,
223
- SE: /\A\d{3}[ ]?\d{2}\z/,
224
- SK: /\A[089]\d{2}[ ]?\d{2}\z/,
223
+ SE: /\A\d{3} ?\d{2}\z/,
224
+ SK: /\A[089]\d{2} ?\d{2}\z/,
225
225
  SL: /\A([A-Z\d\s]){3,}\z/i,
226
226
  SB: /\A([A-Z\d\s]){3,}\z/i,
227
227
  SR: /\A([A-Z\d\s]){3,}\z/i,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module ValidatesZipcode
3
3
  class Formatter
4
- WORD_CHAR_AND_DIGIT = /[A-Z0-9]/.freeze
4
+ WORD_CHAR_AND_DIGIT = /[A-Z0-9]/
5
5
 
6
6
  ZIPCODES_TRANSFORMATIONS = {
7
7
  AT: ->(z) { z.scan(/\d/).join },
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ValidatesZipcode
3
- VERSION = '0.6.1'
3
+ VERSION = '0.7.0'
4
4
  end
@@ -9,12 +9,12 @@ require 'validates_zipcode/zipcode'
9
9
  require 'validates_zipcode/formatter'
10
10
 
11
11
  module ValidatesZipcode
12
- def self.valid?(*args)
13
- build_zipcode(*args).valid?
12
+ def self.valid?(*)
13
+ build_zipcode(*).valid?
14
14
  end
15
15
 
16
- def self.format(*args)
17
- build_zipcode(*args).format
16
+ def self.format(*)
17
+ build_zipcode(*).format
18
18
  end
19
19
 
20
20
  def self.build_zipcode(zipcode, country_alpha2, options = {})
@@ -41,6 +41,6 @@ describe ValidatesZipcode::Formatter, '#format' do
41
41
 
42
42
  def check_format(country, formatting)
43
43
  from_zip, to_zip = formatting.first
44
- expect(::ValidatesZipcode::Formatter.new(zipcode: from_zip, country_alpha2: country).format).to eq(to_zip)
44
+ expect(ValidatesZipcode::Formatter.new(zipcode: from_zip, country_alpha2: country).format).to eq(to_zip)
45
45
  end
46
46
  end
data/spec/spec_helper.rb CHANGED
@@ -344,11 +344,11 @@ TEST_DATA = {
344
344
  ]
345
345
  },
346
346
  KR: {
347
- valid: [
348
- '72315',
349
- '723-150',
350
- '11011',
351
- '110-110'
347
+ valid: %w[
348
+ 72315
349
+ 723-150
350
+ 11011
351
+ 110-110
352
352
  ],
353
353
  invalid: [
354
354
  nil,
@@ -584,10 +584,10 @@ TEST_DATA = {
584
584
  ]
585
585
  },
586
586
  CL: {
587
- valid: [
588
- '123-1233',
589
- '000-0000',
590
- '1234567'
587
+ valid: %w[
588
+ 123-1233
589
+ 000-0000
590
+ 1234567
591
591
  ],
592
592
  invalid: [
593
593
  nil,
@@ -915,10 +915,10 @@ TEST_DATA = {
915
915
  ]
916
916
  },
917
917
  LU: {
918
- valid: [
919
- 'L-5635',
920
- 'L5635',
921
- '5635'
918
+ valid: %w[
919
+ L-5635
920
+ L5635
921
+ 5635
922
922
  ],
923
923
  invalid: [
924
924
  nil,
@@ -2163,12 +2163,12 @@ TEST_DATA = {
2163
2163
  ]
2164
2164
  },
2165
2165
  BR: {
2166
- valid: [
2167
- '58397-000',
2168
- '58915-000',
2169
- '58763000',
2170
- '58935-000',
2171
- '12345678'
2166
+ valid: %w[
2167
+ 58397-000
2168
+ 58915-000
2169
+ 58763000
2170
+ 58935-000
2171
+ 12345678
2172
2172
  ],
2173
2173
  invalid: [
2174
2174
  nil,
@@ -2665,11 +2665,11 @@ TEST_DATA = {
2665
2665
  ]
2666
2666
  },
2667
2667
  JP: {
2668
- valid: [
2669
- '1029200',
2670
- '102-9200',
2671
- '408-0301',
2672
- '207-1000'
2668
+ valid: %w[
2669
+ 1029200
2670
+ 102-9200
2671
+ 408-0301
2672
+ 207-1000
2673
2673
  ],
2674
2674
  invalid: [
2675
2675
  nil,
@@ -2767,10 +2767,10 @@ TEST_DATA = {
2767
2767
  ]
2768
2768
  },
2769
2769
  LV: {
2770
- valid: [
2771
- 'LV-1234',
2772
- 'LV-8735',
2773
- '8735'
2770
+ valid: %w[
2771
+ LV-1234
2772
+ LV-8735
2773
+ 8735
2774
2774
  ],
2775
2775
  invalid: [
2776
2776
  nil,
@@ -3006,9 +3006,9 @@ TEST_DATA = {
3006
3006
  ]
3007
3007
  },
3008
3008
  PT: {
3009
- valid: [
3010
- '4500',
3011
- '4500-250'
3009
+ valid: %w[
3010
+ 4500
3011
+ 4500-250
3012
3012
  ],
3013
3013
  invalid: [
3014
3014
  nil,
@@ -17,7 +17,13 @@ describe ValidatesZipcode, '#validate_each' do
17
17
 
18
18
  context 'does not validate with invalid zipcodes' do
19
19
  values[:invalid].each do |zipcode|
20
- display_name = zipcode.nil? ? 'nil' : zipcode.blank? ? 'blank' : zipcode
20
+ display_name = if zipcode.nil?
21
+ 'nil'
22
+ elsif zipcode.blank?
23
+ 'blank'
24
+ else
25
+ zipcode
26
+ end
21
27
 
22
28
  it display_name.to_s do
23
29
  record = build_record(zipcode, country_code)
@@ -73,7 +79,7 @@ describe ValidatesZipcode, '.valid?' do
73
79
  end
74
80
 
75
81
  it 'is false with an invalid zipcode for a given country code' do
76
- ['1234', '12345-12345', 'D0D0D0', 'invalid_zip'].each do |zipcode|
82
+ %w[1234 12345-12345 D0D0D0 invalid_zip].each do |zipcode|
77
83
  expect(ValidatesZipcode.valid?(zipcode, 'ES')).to eq(false)
78
84
  end
79
85
  end
@@ -82,7 +88,7 @@ describe ValidatesZipcode, '.valid?' do
82
88
  expect(ValidatesZipcode.valid?('12345', 'ZZ')).to eq(true)
83
89
  end
84
90
 
85
- it "is false with a malformed country code that is not a valid ISO 3166-1 alpha-2 code" do
91
+ it 'is false with a malformed country code that is not a valid ISO 3166-1 alpha-2 code' do
86
92
  expect(ValidatesZipcode.valid?('Sw1A 2aA', 'UKXXXXX')).to eq(false)
87
93
  expect(ValidatesZipcode.valid?('12345', 'USA')).to eq(false) # 3 letters
88
94
  expect(ValidatesZipcode.valid?('12345', 'U')).to eq(false) # 1 letter
@@ -146,6 +152,7 @@ end
146
152
 
147
153
  class ValidationDummyClass
148
154
  include ::ActiveModel::Validations
155
+
149
156
  attr_accessor :zipcode, :country_alpha2
150
157
 
151
158
  def self.name
@@ -11,22 +11,18 @@ Gem::Specification.new do |s|
11
11
  s.email = ['dgilperez@gmail.com']
12
12
  s.summary = 'Localizable zipcode validation for Rails.'
13
13
  s.description = 'Adds zipcode validation methods to ActiveModel considering different country zipcode formats.'
14
- s.homepage = 'http://github.com/dgilperez/validates_zipcode'
14
+ s.homepage = 'https://github.com/dgilperez/validates_zipcode'
15
15
  s.license = 'MIT'
16
16
 
17
17
  s.files = `git ls-files -z`.split("\x0")
18
18
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
20
19
  s.require_paths = %w[lib]
21
20
 
22
- s.required_ruby_version = '>= 2.4'
21
+ s.required_ruby_version = '>= 3.3'
23
22
 
24
- s.add_dependency 'activemodel', '>= 4.2.0'
23
+ s.add_dependency 'activemodel', '>= 8.0'
25
24
 
26
- s.add_development_dependency 'appraisal'
27
- s.add_development_dependency 'bundler'
28
- s.add_development_dependency 'rake', '>= 12.3.3'
29
- s.add_development_dependency 'rspec'
30
- s.add_development_dependency 'rubocop'
31
- s.add_development_dependency 'rubocop-rails'
25
+ s.metadata['changelog_uri'] = "#{s.homepage}/blob/master/CHANGELOG.md"
26
+ s.metadata['source_code_uri'] = s.homepage
27
+ s.metadata['rubygems_mfa_required'] = 'true'
32
28
  end