validate_zipcode 1.1.0 → 1.1.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 +4 -4
- data/LIST.md +12 -0
- data/README.md +3 -8
- data/lib/validate_zipcode/regex.rb +30 -0
- data/lib/validate_zipcode/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 856912fbbc0804e0f85eeec9007ec2a7dfbd621d
|
4
|
+
data.tar.gz: cfe437d06598dcc55c3e63220cb1e9f8abfe218b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3ffede4e62d799a42d9f508aa42b7edcab5f799853c55949b81ded365ebac19522c68a9d5c9cfd5341f1574fb14def3f4a903dc28ff0f3c982cd921d549b5b6
|
7
|
+
data.tar.gz: cc527b7c803363b08ccbd49df873c1f7f5a942b042ced3c7080d33f55d5a6d9afa88f285c37f01c7e726677e7692917a46285dfed9bb642f483ede06d099b394
|
data/LIST.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
## List of country identification
|
2
|
+
|
3
|
+
| Country | Identification | Format | Link |
|
4
|
+
|:-------:|:------------:|:-----------:|:-----------:|
|
5
|
+
| Brazil | BR | 35001-345 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/braEn.pdf) |
|
6
|
+
| China | CN | 200082 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/chnEn.pdf) |
|
7
|
+
| Germany or Deutsch | DE | 81545 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/deuEn.pdf) |
|
8
|
+
| France | FR | 75007 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/fraEn.pdf) |
|
9
|
+
| Italy | IT | 20090 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/itaEn.pdf) |
|
10
|
+
| Japan | JP | 208–0032 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/jpnEn.pdf) |
|
11
|
+
| Spain | ES | 28001 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/espEn.pdf) |
|
12
|
+
| United States | US | 90410 or 10118-0229 | [documentation](http://www.upu.int/fileadmin/documentsFiles/activities/addressingUnit/usaEn.pdf) |
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Adds ZipCode / PostalCode validation support to Rails (ActiveModel) and test it in a simple way.
|
4
4
|
|
5
|
-
Any other country's postal code that not on the [list of country identification](https://github.com/RamonHossein/validate_zipcode
|
5
|
+
Any other country's postal code that not on the [list of country identification](https://github.com/RamonHossein/validate_zipcode/blob/master/LIST.md) will validate without errors.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -26,19 +26,14 @@ Just use as any other validator passing the country:
|
|
26
26
|
|
27
27
|
ValidateZipcode expects the model has an attribute called country to contain the country identification.
|
28
28
|
|
29
|
+
This Gem use as country identification the codes supplied by the ISO 3166-2 (International Organization for Standardization).
|
30
|
+
|
29
31
|
```ruby
|
30
32
|
class Address < ActiveRecord::Base
|
31
33
|
validates :zipcode, zipcode: {country: "US"}
|
32
34
|
end
|
33
35
|
```
|
34
36
|
|
35
|
-
## List of country identification
|
36
|
-
|
37
|
-
| Country | Identification | Format | Link |
|
38
|
-
|:-------:|:------------:|:-----------:|:-----------:|
|
39
|
-
| United States | US | 90410 or 10118-0229 | no link yet |
|
40
|
-
| Brazil | BR | 35001-345 | no link yet |
|
41
|
-
|
42
37
|
## Error Message
|
43
38
|
|
44
39
|
If you need to localize the error message, just add this to your I18n locale file:
|
@@ -9,5 +9,35 @@ module ValidateZipcode
|
|
9
9
|
match = zipcode =~ /^([0-9]{5}-[0-9]{3})$|([0-9]{8})$/
|
10
10
|
match == 0 ? true : false
|
11
11
|
end
|
12
|
+
|
13
|
+
def self.FR(zipcode)
|
14
|
+
match = zipcode =~ /^([0-9]{5})$/
|
15
|
+
match == 0 ? true : false
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.IT(zipcode)
|
19
|
+
match = zipcode =~ /^([0-9]{5})$/
|
20
|
+
match == 0 ? true : false
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.DE(zipcode)
|
24
|
+
match = zipcode =~ /^([0-9]{5})$/
|
25
|
+
match == 0 ? true : false
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.ES(zipcode)
|
29
|
+
match = zipcode =~ /^([0-9]{5})$/
|
30
|
+
match == 0 ? true : false
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.CN(zipcode)
|
34
|
+
match = zipcode =~ /^([0-9]{6})$/
|
35
|
+
match == 0 ? true : false
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.JP(zipcode)
|
39
|
+
match = zipcode =~ /^([0-9]{3}-[0-9]{4})$|([0-9]{7})$/
|
40
|
+
match == 0 ? true : false
|
41
|
+
end
|
12
42
|
end
|
13
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validate_zipcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RamonHossein
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- CODE_OF_CONDUCT.md
|
94
94
|
- Gemfile
|
95
95
|
- LICENSE.txt
|
96
|
+
- LIST.md
|
96
97
|
- README.md
|
97
98
|
- Rakefile
|
98
99
|
- bin/console
|