validates_zipcode 0.5.2 → 0.5.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9c878568a2af03e823438d845d8a0d628ed03985bb0f418b54a7348c3acc616
4
- data.tar.gz: 309f3aa2cd404dad08dae5c80a49b55fef322f195283417adefdf9dd5f269c9b
3
+ metadata.gz: dabc7eb750e5922949d9caebe9616e87d2c571f6caa64f56f0779106235c2e89
4
+ data.tar.gz: 20ff39a51cd9f7d71dbfabef44eaf985c1e77e1df070f78d0fcceccbd052f2da
5
5
  SHA512:
6
- metadata.gz: 5ca4df588c1ad58357a6c55a1cafb213f1cb927381cbfb8689c9039949c4c0f93aace2094a0eb262fa5d5b1cba28cb90920b4730cb1102ef54907b9d97c35016
7
- data.tar.gz: b32c12a15baf303f80c111f8018b2edfbe230f6c6fd62224bce776e6d305ab75038fc7e7bf0f926354e3ebe271407961c3e5ba6055580cbc2e4f6abfb9794d66
6
+ metadata.gz: dc1fde962b62625f8877f34479fe76e4a9a8e9aac7bd9ed598c52ad68c41a5d3ed01031c83c23bd4c4c30a810450b724c53b4bafc5ee51dc5853688fe64d2638
7
+ data.tar.gz: ad65f8eec393ce26b63a23c2f82a2e64107e0e869e5ebd7c0b7689e00a9906dd8ba98bc4197364885de332eb49cc68a704b6bd449e3eb46246d0c12f73a6cbca
@@ -32,7 +32,7 @@ module ValidatesZipcode
32
32
  SG: /\A\d{6}\z/,
33
33
  DZ: /\A\d{5}\z/,
34
34
  AD: /\AAD\d{3}\z/,
35
- AR: /\A[A-HJ-NP-Z]{1}\d{4}([A-Z]{3})?\z/,
35
+ AR: /\A([A-HJ-NP-Z]{1}\d{4}([A-Z]{3})?|\d{4})\z/,
36
36
  AM: /\A(37)?\d{4}\z/,
37
37
  BH: /\A(1[0-2]|[1-9])\d{2}\z/,
38
38
  BD: /\A\d{4}\z/,
@@ -42,7 +42,7 @@ module ValidatesZipcode
42
42
  BA: /\A\d{5}\z/,
43
43
  BN: /\A[BKTP][A-Z][ ]?\d{4}\z/i,
44
44
  BG: /\A\d{4}\z/,
45
- KH: /\A\d{5}\z/,
45
+ KH: /\A\d{6}\z/,
46
46
  CV: /\A\d{4}\z/,
47
47
  CL: /\A\d{3}[-]?\d{4}\z/,
48
48
  HR: /\A\d{5}\z/,
@@ -80,7 +80,7 @@ module ValidatesZipcode
80
80
  NG: /\A\d{6}\z/,
81
81
  OM: /\A(PC )?\d{3}\z/i,
82
82
  PK: /\A\d{5}\z/,
83
- PY: /\A\d{4}\z/,
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
86
  PR: /\A00[679]\d{2}([ \-]\d{4})?\z/,
@@ -158,7 +158,8 @@ module ValidatesZipcode
158
158
  BJ: /\A([A-Z\d\s]){3,}\z/i,
159
159
  BT: /\A\d{5}\z/,
160
160
  BQ: /\A([A-Z\d\s]){3,}\z/i,
161
- BO: /\A\d{4}\z/,
161
+ # NOTE: Bolivia has no postal codes
162
+ # BO: /\A\d{4}\z/,
162
163
  BW: /\A([A-Z\d\s]){3,}\z/i,
163
164
  CF: /\A([A-Z\d\s]){3,}\z/i,
164
165
  CG: /\A([A-Z\d\s]){3,}\z/i,
@@ -210,7 +211,7 @@ module ValidatesZipcode
210
211
  MW: /\A([A-Z\d\s]){3,}\z/i,
211
212
  MZ: /\A\d{4}\z/,
212
213
  NA: /\A\d{5}\z/,
213
- NP: /\A\d{6}\z/,
214
+ NP: /\A\d{5}\z/,
214
215
  NR: /\A([A-Z\d\s]){3,}\z/i,
215
216
  PT: /\A\d{4}([\-]\d{3})?\z/,
216
217
  PS: /\A\d{3}\z/,
@@ -19,7 +19,7 @@ module ValidatesZipcode
19
19
  PL: ->(z) { z.scan(/\d/).insert(2, '-').join },
20
20
  SK: :CZ,
21
21
  UK: :GB,
22
- MT: :GB,
22
+ MT: ->(z) { z.upcase.scan(WORD_CHAR_AND_DIGIT).insert(3, ' ').join },
23
23
  FK: :GB,
24
24
  GS: :GB,
25
25
  PN: :GB,
@@ -35,7 +35,7 @@ module ValidatesZipcode
35
35
 
36
36
  return if ValidatesZipcode::Zipcode.new(options).valid?
37
37
 
38
- message = @message || I18n.t('errors.messages.invalid_zipcode', value: value, default: 'Zipcode is invalid')
38
+ message = @message || I18n.t('errors.messages.invalid_zipcode', value: value, default: 'is invalid')
39
39
  record.errors.add(attribute, :invalid_zipcode, message: message)
40
40
  end
41
41
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ValidatesZipcode
3
- VERSION = '0.5.2'
3
+ VERSION = '0.5.4'
4
4
  end
@@ -35,6 +35,10 @@ describe ValidatesZipcode::Formatter, '#format' do
35
35
  it { check_format('US', '22162 1010' => '22162-1010') }
36
36
  end
37
37
 
38
+ context 'MT' do
39
+ it { check_format('MT', 'GZR1020' => 'GZR 1020') }
40
+ end
41
+
38
42
  def check_format(country, formatting)
39
43
  from_zip, to_zip = formatting.first
40
44
  expect(::ValidatesZipcode::Formatter.new(zipcode: from_zip, country_alpha2: country).format).to eq(to_zip)
data/spec/spec_helper.rb CHANGED
@@ -423,6 +423,7 @@ TEST_DATA = {
423
423
  valid: %w[
424
424
  C1234CHN
425
425
  C1234
426
+ 6000
426
427
  ],
427
428
  invalid: [
428
429
  nil,
@@ -1116,6 +1117,7 @@ TEST_DATA = {
1116
1117
  2566
1117
1118
  6261
1118
1119
  7113
1120
+ 111421
1119
1121
  ],
1120
1122
  invalid: [
1121
1123
  nil,
@@ -2218,22 +2220,6 @@ TEST_DATA = {
2218
2220
  '12'
2219
2221
  ]
2220
2222
  },
2221
- BO: {
2222
- valid: %w[
2223
- 7113
2224
- 2566
2225
- 6261
2226
- 7113
2227
- ],
2228
- invalid: [
2229
- nil,
2230
- '',
2231
- 'invalid_zip',
2232
- '12345',
2233
- '1234-1234',
2234
- 'D0D0D0'
2235
- ]
2236
- },
2237
2223
  BW: {
2238
2224
  valid: %w[
2239
2225
  42511
@@ -2977,16 +2963,16 @@ TEST_DATA = {
2977
2963
  },
2978
2964
  NP: {
2979
2965
  valid: %w[
2980
- 071134
2981
- 025663
2982
- 662612
2983
- 071135
2966
+ 44600
2967
+ 44700
2968
+ 44800
2969
+ 32907
2984
2970
  ],
2985
2971
  invalid: [
2986
2972
  nil,
2987
2973
  '',
2988
2974
  'invalid_zip',
2989
- '12345',
2975
+ '123456',
2990
2976
  '123456-123456',
2991
2977
  'D0D0D0'
2992
2978
  ]
@@ -118,7 +118,7 @@ def zipcode_should_be_invalid(record, _zipcode, options = {})
118
118
  ValidatesZipcode::Validator.new(options.merge(attributes: :zipcode)).validate(record)
119
119
 
120
120
  expect(record.errors.size).to eq 1
121
- expect(record.errors.messages[:zipcode]).to include 'Zipcode is invalid'
121
+ expect(record.errors.messages[:zipcode]).to include 'is invalid'
122
122
  end
123
123
 
124
124
  def zipcode_should_be_invalid_with_custom_message(record, _zipcode, options = {})
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_zipcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Gil
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-01-21 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activemodel
@@ -155,7 +154,6 @@ homepage: http://github.com/dgilperez/validates_zipcode
155
154
  licenses:
156
155
  - MIT
157
156
  metadata: {}
158
- post_install_message:
159
157
  rdoc_options: []
160
158
  require_paths:
161
159
  - lib
@@ -170,8 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
168
  - !ruby/object:Gem::Version
171
169
  version: '0'
172
170
  requirements: []
173
- rubygems_version: 3.3.7
174
- signing_key:
171
+ rubygems_version: 3.6.9
175
172
  specification_version: 4
176
173
  summary: Localizable zipcode validation for Rails.
177
174
  test_files: