validates_zipcode 0.5.2 → 0.5.3

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: b9c878568a2af03e823438d845d8a0d628ed03985bb0f418b54a7348c3acc616
4
- data.tar.gz: 309f3aa2cd404dad08dae5c80a49b55fef322f195283417adefdf9dd5f269c9b
3
+ metadata.gz: eaccf2cf4e72190040829da37f3da72cd319020b9e97c1dd3a064cb1b4d6b381
4
+ data.tar.gz: dac1daf1928badb6279f0007ae20ab969e854adacbd8e0a25d7e4ded91483125
5
5
  SHA512:
6
- metadata.gz: 5ca4df588c1ad58357a6c55a1cafb213f1cb927381cbfb8689c9039949c4c0f93aace2094a0eb262fa5d5b1cba28cb90920b4730cb1102ef54907b9d97c35016
7
- data.tar.gz: b32c12a15baf303f80c111f8018b2edfbe230f6c6fd62224bce776e6d305ab75038fc7e7bf0f926354e3ebe271407961c3e5ba6055580cbc2e4f6abfb9794d66
6
+ metadata.gz: 52810b93259d83ba29088bc3b3eb0596bb89f15d8d92f7b8947bf08333f7191fa7e37946dbed18d4045bb4d4fd0d574f73e1c94846bc2c95f39295a42e996616
7
+ data.tar.gz: 3129ba6f20cbe9850aa9448b98271bee9e0d60496fbd47ed9f4df55db896377aa20998832864d37388bc0c4d8c18b2ee19955ff4d4e0de89d4628061842c5861
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 0.5.3
8
+
9
+ - See commits up to 4e5a3132061d57d220d1616beb15d15a47d301df
10
+
7
11
  ## 0.5.2
8
12
 
9
13
  - Added support for Puerto Rico, thanks to ~ @tahanson
@@ -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/,
@@ -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.3'
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,
@@ -2218,22 +2219,6 @@ TEST_DATA = {
2218
2219
  '12'
2219
2220
  ]
2220
2221
  },
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
2222
  BW: {
2238
2223
  valid: %w[
2239
2224
  42511
@@ -2977,16 +2962,16 @@ TEST_DATA = {
2977
2962
  },
2978
2963
  NP: {
2979
2964
  valid: %w[
2980
- 071134
2981
- 025663
2982
- 662612
2983
- 071135
2965
+ 44600
2966
+ 44700
2967
+ 44800
2968
+ 32907
2984
2969
  ],
2985
2970
  invalid: [
2986
2971
  nil,
2987
2972
  '',
2988
2973
  'invalid_zip',
2989
- '12345',
2974
+ '123456',
2990
2975
  '123456-123456',
2991
2976
  'D0D0D0'
2992
2977
  ]
@@ -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,14 @@
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Gil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-21 00:00:00.000000000 Z
11
+ date: 2024-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  - !ruby/object:Gem::Version
171
171
  version: '0'
172
172
  requirements: []
173
- rubygems_version: 3.3.7
173
+ rubygems_version: 3.5.17
174
174
  signing_key:
175
175
  specification_version: 4
176
176
  summary: Localizable zipcode validation for Rails.