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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 752ff8cc4665b24fef8bc2e4a8c72d3c14d2d55f
4
- data.tar.gz: e104573885ae882fc26dd6bde82eadcf8a5e3cf9
3
+ metadata.gz: 856912fbbc0804e0f85eeec9007ec2a7dfbd621d
4
+ data.tar.gz: cfe437d06598dcc55c3e63220cb1e9f8abfe218b
5
5
  SHA512:
6
- metadata.gz: cb002149675737d17d843e6a40d04744dde8581c97f7b2311efa3cd9ff6f33d5e102e1f65af848883cdd051cd304abcf6d4acb06118d88da6d3ca84e4fa05e68
7
- data.tar.gz: 81562a58cd1287ff66bf14d765c448e6c31c27d80a0494d3f800307d4f2e4101ef928a15bf0765d8008bd0de7d11c55453ed2df6713403eacf62426cf4d9c5ed
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#list-of-country-identification) will validate without errors.
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
@@ -1,3 +1,3 @@
1
1
  module ValidateZipcode
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  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.0
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-05-26 00:00:00.000000000 Z
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