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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/validates_zipcode/cldr_regex_collection.rb +5 -4
- data/lib/validates_zipcode/formatter.rb +1 -1
- data/lib/validates_zipcode/validator.rb +1 -1
- data/lib/validates_zipcode/version.rb +1 -1
- data/spec/format_zipcode_spec.rb +4 -0
- data/spec/spec_helper.rb +6 -21
- data/spec/validates_zipcode_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaccf2cf4e72190040829da37f3da72cd319020b9e97c1dd3a064cb1b4d6b381
|
4
|
+
data.tar.gz: dac1daf1928badb6279f0007ae20ab969e854adacbd8e0a25d7e4ded91483125
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52810b93259d83ba29088bc3b3eb0596bb89f15d8d92f7b8947bf08333f7191fa7e37946dbed18d4045bb4d4fd0d574f73e1c94846bc2c95f39295a42e996616
|
7
|
+
data.tar.gz: 3129ba6f20cbe9850aa9448b98271bee9e0d60496fbd47ed9f4df55db896377aa20998832864d37388bc0c4d8c18b2ee19955ff4d4e0de89d4628061842c5861
|
data/CHANGELOG.md
CHANGED
@@ -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})
|
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{
|
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
|
-
|
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{
|
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/,
|
@@ -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: '
|
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
|
data/spec/format_zipcode_spec.rb
CHANGED
@@ -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
|
-
|
2981
|
-
|
2982
|
-
|
2983
|
-
|
2965
|
+
44600
|
2966
|
+
44700
|
2967
|
+
44800
|
2968
|
+
32907
|
2984
2969
|
],
|
2985
2970
|
invalid: [
|
2986
2971
|
nil,
|
2987
2972
|
'',
|
2988
2973
|
'invalid_zip',
|
2989
|
-
'
|
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 '
|
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.
|
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:
|
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.
|
173
|
+
rubygems_version: 3.5.17
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Localizable zipcode validation for Rails.
|