validates_zipcode 0.0.19 → 0.0.20
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/gemfiles/rails_3.2.gemfile.lock +3 -3
- data/gemfiles/rails_4.0.gemfile.lock +3 -3
- data/gemfiles/rails_4.1.gemfile.lock +3 -3
- data/gemfiles/rails_4.2.gemfile.lock +3 -3
- data/gemfiles/rails_5.0.gemfile.lock +3 -3
- data/lib/validates_zipcode/cldr_regex_collection.rb +4 -2
- data/lib/validates_zipcode/version.rb +1 -1
- data/spec/validates_zipcode_spec.rb +27 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99f0626521efd52efa07619ed05806a56f2ffafb
|
4
|
+
data.tar.gz: e3cc9c7095befadcb691db961c928436a82f020a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 502ce7e4cc3ce8c1907c3e14c2722e9946a5cbf68f3dd80f825099b3030b73a67ea9064eb612d7da6a9e8c43c62c1e7a06933ceb8a02eb059b2d8c2fa999957b
|
7
|
+
data.tar.gz: 68a49d8d2f215dfdcfbbc3c9659516e7dfc022c62fe5189d221f0a7644af812139aa7279cf79f6cf497c16ef3a42c40f2a363d4d0d2e82eb7cc61609707fd3ad
|
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,10 @@
|
|
5
5
|
module ValidatesZipcode
|
6
6
|
module CldrRegexpCollection
|
7
7
|
ZIPCODES_REGEX = {
|
8
|
-
GB: /\AGIR
|
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})|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}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)\z/,
|
234
236
|
UG: /\A([a-zA-Z\d\s]){3,}\z/,
|
235
237
|
UM: /\A([a-zA-Z\d\s]){3,}\z/,
|
236
238
|
UY: /\A([a-zA-Z\d\s]){3,}\z/,
|
@@ -263,6 +263,33 @@ describe ValidatesZipcode, '#validate_each' do
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
|
+
['UK', 'GB'].each do |cc|
|
267
|
+
context cc do
|
268
|
+
it 'validates with a valid zipcode' do
|
269
|
+
[
|
270
|
+
'ID1 1QD',
|
271
|
+
'M32 0JG',
|
272
|
+
'NE30 1DP',
|
273
|
+
'OX49 5NU',
|
274
|
+
'SW1A 2AA',
|
275
|
+
'W1K 7DA',
|
276
|
+
'id1 1qd',
|
277
|
+
'Sw1A 2aA'
|
278
|
+
].each do |zipcode|
|
279
|
+
record = build_record(zipcode, cc)
|
280
|
+
zipcode_should_be_valid(record)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'does not validate with an invalid zipcode' do
|
285
|
+
[nil, '', 'nope', 'id11qd', 'SW1A2AA'].each do |zipcode|
|
286
|
+
record = build_record(zipcode, cc)
|
287
|
+
zipcode_should_be_invalid(record, nil)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
266
293
|
context 'USA' do
|
267
294
|
it 'does not add errors with a valid zipcode' do
|
268
295
|
record = build_record('93108', 'US')
|
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.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Gil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
143
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.6.
|
144
|
+
rubygems_version: 2.6.12
|
145
145
|
signing_key:
|
146
146
|
specification_version: 4
|
147
147
|
summary: Localizable zipcode validation for Rails.
|