validates_zipcode 0.7.0 → 0.7.1

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: 9477a8a23b5970016662d5efd5017f0df92de613188e6792f66b6415cdb4e692
4
- data.tar.gz: 1d9ab247ef83a611f2aedb38fc43ce0a6b902ecfb954ba7b720fe167ddc86d0d
3
+ metadata.gz: 4739650fc1f383f655910e2b5d3c9cf667722be3cbe5def83505d58293a1a5e7
4
+ data.tar.gz: d2742fca653ebe14d41a336149e0c2a2399946c14850f616c1c4b384553841b0
5
5
  SHA512:
6
- metadata.gz: 6ebf50f76a29960ef94061ada80ab166946220135e74ef60513ef6e95de275c113a9450513fe0803f184eb69ee0639467dec5e79d6026a258c3bc10c3a9e64cd
7
- data.tar.gz: 7bca3b4f6cf1149bb3d9b3337d569486300e4dc07ece2d3ba2a88b23b70574bc89c0d5aa4ecf351c4a8be76c2e7725bd3e0e6e5a95c7f6da89c8c88794ff66f2
6
+ metadata.gz: 92b1204153072f474f1a90cf168c64bfcef2c1c2cc2125cc23807e544b134eb2cd12acf96db2658fc560fd96f3287a4ed080ecb4028790a4b99c523dbc7560cf
7
+ data.tar.gz: 5e7a7ca7026c869aa5e1f7f4aba75d19d3142e6b69f45f2831763c997a1811f785b6c60610817a10e576152fa367d0b01f514cf811f421fab8f93bb07cf60422
data/CHANGELOG.md CHANGED
@@ -4,15 +4,26 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 0.7.1
8
+
9
+ - Fix the United Kingdom (GB, UK) postcode pattern to anchor both alternatives. `\A` only applied to `GIR 0AA` and `\z` only to the regular form, so strings like `hello SW1A 2AA` or `GIR 0AA, London` were accepted — fixes #76. Thanks to ~ @bardrop
10
+
7
11
  ## 0.7.0
8
12
 
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.
13
+ **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 (0.6.1 has the same postcode fixes).
10
14
 
11
15
  - 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
16
  - Replace the defunct Travis CI setup with GitHub Actions
13
17
  - 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
14
18
  - 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
15
19
 
20
+ ## 0.6.1
21
+
22
+ Backport of the postcode fixes in 0.7.0 for apps that cannot move to Ruby >= 3.3 and Rails >= 8.0 yet, released from the `0-6-stable` branch. Requirements are unchanged from 0.6.0.
23
+
24
+ - Accept Nigeria's (NG) 11-character digital postcode, such as `EK-01-A03-FK-01`, alongside the six-digit code. Thanks to ~ @Adeniyikayodee
25
+ - Fix the Moldova (MD) postcode pattern — fixes #73
26
+
16
27
  ## 0.6.0
17
28
 
18
29
  **Heads up:** This release changes the behaviour of `ValidatesZipcode.valid?` when an unknown or malformed country code is passed. Previously, passing a country code not recognised by the gem (e.g. `'UKXXXXX'`) would return `true` — no regex to match against meant no failure. It will now return `false`.
@@ -5,8 +5,8 @@
5
5
  module ValidatesZipcode
6
6
  module CldrRegexpCollection
7
7
  ZIPCODES_REGEX = {
8
- GB: /\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,
9
- UK: /\AGIR ?0AA|((([A-Z]\d{1,2})|(([A-Z][A-HJ-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end
data/spec/spec_helper.rb CHANGED
@@ -13,7 +13,9 @@ TEST_DATA = {
13
13
  'id1 1qd',
14
14
  'Sw1A 2aA',
15
15
  'id11qd',
16
- 'SW1A2AA'
16
+ 'SW1A2AA',
17
+ 'GIR 0AA',
18
+ 'gir0aa'
17
19
  ],
18
20
  invalid: [
19
21
  nil,
@@ -21,7 +23,11 @@ TEST_DATA = {
21
23
  'invalid_zip',
22
24
  'nope',
23
25
  'id11qd1000',
24
- '28001'
26
+ '28001',
27
+ 'GIR 0AA1',
28
+ 'GIR 0AA, London',
29
+ 'hello SW1A 2AA',
30
+ '12345 SW1A 2AA'
25
31
  ]
26
32
  },
27
33
  UK: {
@@ -35,7 +41,9 @@ TEST_DATA = {
35
41
  'id1 1qd',
36
42
  'Sw1A 2aA',
37
43
  'id11qd',
38
- 'SW1A2AA'
44
+ 'SW1A2AA',
45
+ 'GIR 0AA',
46
+ 'gir0aa'
39
47
  ],
40
48
  invalid: [
41
49
  nil,
@@ -43,7 +51,11 @@ TEST_DATA = {
43
51
  'invalid_zip',
44
52
  'nope',
45
53
  'id11qd1000',
46
- '28001'
54
+ '28001',
55
+ 'GIR 0AA1',
56
+ 'GIR 0AA, London',
57
+ 'hello SW1A 2AA',
58
+ '12345 SW1A 2AA'
47
59
  ]
48
60
  },
49
61
  JE: {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_zipcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Gil