validate_zipcode 1.0.0 → 1.1.0

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: a6c2ef37df39673a9559e53648cd5a4be7fdb4b3
4
- data.tar.gz: 326d5dcaf21f869090d1866947caf29a97713a3c
3
+ metadata.gz: 752ff8cc4665b24fef8bc2e4a8c72d3c14d2d55f
4
+ data.tar.gz: e104573885ae882fc26dd6bde82eadcf8a5e3cf9
5
5
  SHA512:
6
- metadata.gz: b26f49417775eec72551521b83a1fd50b2ec9b57a8bb89179e9b272d30bac86f4b0308a5b9534ac7d84e3fe534fe860cf6ff95297de1367ddd4630f854424a69
7
- data.tar.gz: 2fcdde805fb7832c1ddd175266e94dc4e6ea4634757ba55cfd2c22de7646c2f84d7080ed2f7f1072ad02217c6635f0549271666478a875982842b2ea85ae8570
6
+ metadata.gz: cb002149675737d17d843e6a40d04744dde8581c97f7b2311efa3cd9ff6f33d5e102e1f65af848883cdd051cd304abcf6d4acb06118d88da6d3ca84e4fa05e68
7
+ data.tar.gz: 81562a58cd1287ff66bf14d765c448e6c31c27d80a0494d3f800307d4f2e4101ef928a15bf0765d8008bd0de7d11c55453ed2df6713403eacf62426cf4d9c5ed
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # ValidateZipcode
2
2
 
3
- Adds zip code / postal code validation support to Rails (ActiveModel) and test it in a simple way.
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 in this list `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#list-of-country-identification) will validate without errors.
6
6
 
7
7
  ## Installation
8
8
 
@@ -24,7 +24,7 @@ Or install it yourself as:
24
24
 
25
25
  Just use as any other validator passing the country:
26
26
 
27
- ValidateZipcode expects the model to have an attribute called country to contain the country identification.
27
+ ValidateZipcode expects the model has an attribute called country to contain the country identification.
28
28
 
29
29
  ```ruby
30
30
  class Address < ActiveRecord::Base
@@ -36,7 +36,8 @@ end
36
36
 
37
37
  | Country | Identification | Format | Link |
38
38
  |:-------:|:------------:|:-----------:|:-----------:|
39
- | United States | US | 12345 or 12345-6789 | no link yet |
39
+ | United States | US | 90410 or 10118-0229 | no link yet |
40
+ | Brazil | BR | 35001-345 | no link yet |
40
41
 
41
42
  ## Error Message
42
43
 
@@ -4,5 +4,10 @@ module ValidateZipcode
4
4
  match = zipcode =~ /^([0-9]{5})$|([0-9]{9})$|([0-9]{5}-[0-9]{4})$/
5
5
  match == 0 ? true : false
6
6
  end
7
+
8
+ def self.BR(zipcode)
9
+ match = zipcode =~ /^([0-9]{5}-[0-9]{3})$|([0-9]{8})$/
10
+ match == 0 ? true : false
11
+ end
7
12
  end
8
13
  end
@@ -1,7 +1,8 @@
1
1
  module ValidateZipcode
2
2
  class Validator
3
3
  def initialize(zipcode, locale)
4
- variables(zipcode, locale) unless zipcode.blank?
4
+ @zipcode = zipcode
5
+ variables(locale) unless @zipcode.blank?
5
6
  end
6
7
 
7
8
  def valid?
@@ -10,8 +11,7 @@ module ValidateZipcode
10
11
  end
11
12
 
12
13
  private
13
- def variables(zipcode, locale)
14
- @zipcode = zipcode
14
+ def variables(locale)
15
15
  @match = regex_zipcode(locale.upcase)
16
16
  end
17
17
 
@@ -1,3 +1,3 @@
1
1
  module ValidateZipcode
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
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.0.0
4
+ version: 1.1.0
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-25 00:00:00.000000000 Z
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,4 +128,3 @@ signing_key:
128
128
  specification_version: 4
129
129
  summary: Zip code validation for Rails.
130
130
  test_files: []
131
- has_rdoc: