validates_zipcode 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ead02aab62164e7c94c7e9636e6d88b925f78407
4
- data.tar.gz: e0fcc448e62c75372127adeee6020ab1bb878ca8
3
+ metadata.gz: fc753ae28483c43a47c1b9ddce7ffd1f173eb4ec
4
+ data.tar.gz: d97bc060568e9572b0a4f8eb8c622aa626206b82
5
5
  SHA512:
6
- metadata.gz: 7826163416003ac5cc0271a4ee41e560f5de54e6c8cb44ee469fe66ac9ebf2c87ff5850ec2dfe30829a876d2463b3662ce24c1a3f425d4048ca9359ed2aad680
7
- data.tar.gz: 4310f9cae117c4d810ed6921c417e77190b061f5e1cc12ef6762186f0b1b6d876c8129aa32d689b069c816eb006f3c229d75c0e58281d9f76a244a33d80aeeb4
6
+ metadata.gz: 3763d277e9f3bf990bc7164089d639b04878a0056b2756214f781d7c63f9d847d36a79f380ae25b6a4104e27ab41bbbc34c7eaab4b76d9d5f5c181b6bc911086
7
+ data.tar.gz: 25e77e02daae5d6f408f799023f4f4506ebfc3031aaca0c6c6fc01b7a4994761b40655b5f20f939791fc076f1fe024c55a614858892d4c08c5f149bf39089cdd
@@ -1,6 +1,11 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 0.0.9
5
+
6
+ - Added Code of Conduct from Contributor Covenant ~ @dgilperez
7
+ - Fixed Regex for Greece thanks to @Masa331
8
+
4
9
  ## 0.0.8
5
10
 
6
- - Added ValidatesZipcode.valid?(zipcode, country_alpha2) for usage outside models // @dgilperez
11
+ - Added ValidatesZipcode.valid?(zipcode, country_alpha2) for usage outside models ~ @dgilperez
@@ -0,0 +1,22 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
6
+
7
+ Examples of unacceptable behavior by participants include:
8
+
9
+ * The use of sexualized language or imagery
10
+ * Personal attacks
11
+ * Trolling or insulting/derogatory comments
12
+ * Public or private harassment
13
+ * Publishing other's private information, such as physical or electronic addresses, without explicit permission
14
+ * Other unethical or unprofessional conduct.
15
+
16
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
17
+
18
+ This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
19
+
20
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
21
+
22
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Add zipcode validation support to Rails (ActiveModel), considering different zipcode country formats.
4
4
 
5
- ``ValidatesZipcode`` currently support **259 countries**. Regex data taken from several sources, being the main source the [CLDR](common/supplemental/postalCodeData.xml) database (around 159). Any other country's zipcode will validate without errors.
5
+ ``ValidatesZipcode`` currently support **259 countries**. Regex data taken from several sources, being the main source the [CLDR](http://unicode.org/cldr/trac/browser/tags/release-27-d05/common/supplemental/postalCodeData.xml) database (release 27, around 159). Any other country's zipcode will validate without errors.
6
6
 
7
7
  ``ValidatesZipcode`` works for Rails 3 & 4 and Ruby >= 1.9.3.
8
8
 
@@ -48,6 +48,8 @@ If you need to localize the error message, just add this to your I18n locale fil
48
48
  4. Push to the branch (`git push origin my-new-feature`)
49
49
  5. Create a new Pull Request
50
50
 
51
+ Also, you should read and follow our [Code of Conduct](https://github.com/dgilperez/validates_zipcode/blob/master/CODE_OF_CONDUCT.md).
52
+
51
53
  ## Contributors
52
54
 
53
55
  To see the generous people who have contributed code, take a look at the [contributors list](http://github.com/dgilperez/validates_zipcode/contributors).
@@ -0,0 +1,176 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!DOCTYPE supplementalData SYSTEM "../../common/dtd/ldmlSupplemental.dtd">
3
+ <!--
4
+ Copyright © 1991-2013 Unicode, Inc.
5
+ CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)
6
+ For terms of use, see http://www.unicode.org/copyright.html
7
+ -->
8
+ <supplementalData>
9
+ <version number="$Revision$"/>
10
+ <generation date="$Date$"/>
11
+ <!-- Deprecated in v27. Please see other services that are kept up to date, such as:
12
+ ​ http://i18napis.appspot.com/address/data/US
13
+ ​ http://i18napis.appspot.com/address/data/GB
14
+ ...
15
+ -->
16
+ <postalCodeData>
17
+ <postCodeRegex territoryId="GB" >GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\d{1,4}</postCodeRegex>
18
+ <postCodeRegex territoryId="JE" >JE\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}</postCodeRegex>
19
+ <postCodeRegex territoryId="GG" >GY\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}</postCodeRegex>
20
+ <postCodeRegex territoryId="IM" >IM\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}</postCodeRegex>
21
+ <postCodeRegex territoryId="US" >\d{5}([ \-]\d{4})?</postCodeRegex>
22
+ <postCodeRegex territoryId="CA" >[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ ]?\d[ABCEGHJ-NPRSTV-Z]\d</postCodeRegex>
23
+ <postCodeRegex territoryId="DE" >\d{5}</postCodeRegex>
24
+ <postCodeRegex territoryId="JP" >\d{3}-\d{4}</postCodeRegex>
25
+ <postCodeRegex territoryId="FR" >\d{2}[ ]?\d{3}</postCodeRegex>
26
+ <postCodeRegex territoryId="AU" >\d{4}</postCodeRegex>
27
+ <postCodeRegex territoryId="IT" >\d{5}</postCodeRegex>
28
+ <postCodeRegex territoryId="CH" >\d{4}</postCodeRegex>
29
+ <postCodeRegex territoryId="AT" >\d{4}</postCodeRegex>
30
+ <postCodeRegex territoryId="ES" >\d{5}</postCodeRegex>
31
+ <postCodeRegex territoryId="NL" >\d{4}[ ]?[A-Z]{2}</postCodeRegex>
32
+ <postCodeRegex territoryId="BE" >\d{4}</postCodeRegex>
33
+ <postCodeRegex territoryId="DK" >\d{4}</postCodeRegex>
34
+ <postCodeRegex territoryId="SE" >\d{3}[ ]?\d{2}</postCodeRegex>
35
+ <postCodeRegex territoryId="NO" >\d{4}</postCodeRegex>
36
+ <postCodeRegex territoryId="BR" >\d{5}[\-]?\d{3}</postCodeRegex>
37
+ <postCodeRegex territoryId="PT" >\d{4}([\-]\d{3})?</postCodeRegex>
38
+ <postCodeRegex territoryId="FI" >\d{5}</postCodeRegex>
39
+ <postCodeRegex territoryId="AX" >22\d{3}</postCodeRegex>
40
+ <postCodeRegex territoryId="KR" >\d{3}[\-]\d{3}</postCodeRegex>
41
+ <postCodeRegex territoryId="CN" >\d{6}</postCodeRegex>
42
+ <postCodeRegex territoryId="TW" >\d{3}(\d{2})?</postCodeRegex>
43
+ <postCodeRegex territoryId="SG" >\d{6}</postCodeRegex>
44
+ <postCodeRegex territoryId="DZ" >\d{5}</postCodeRegex>
45
+ <postCodeRegex territoryId="AD" >AD\d{3}</postCodeRegex>
46
+ <postCodeRegex territoryId="AR" >([A-HJ-NP-Z])?\d{4}([A-Z]{3})?</postCodeRegex>
47
+ <postCodeRegex territoryId="AM" >(37)?\d{4}</postCodeRegex>
48
+ <postCodeRegex territoryId="AZ" >\d{4}</postCodeRegex>
49
+ <postCodeRegex territoryId="BH" >((1[0-2]|[2-9])\d{2})?</postCodeRegex>
50
+ <postCodeRegex territoryId="BD" >\d{4}</postCodeRegex>
51
+ <postCodeRegex territoryId="BB" >(BB\d{5})?</postCodeRegex>
52
+ <postCodeRegex territoryId="BY" >\d{6}</postCodeRegex>
53
+ <postCodeRegex territoryId="BM" >[A-Z]{2}[ ]?[A-Z0-9]{2}</postCodeRegex>
54
+ <postCodeRegex territoryId="BA" >\d{5}</postCodeRegex>
55
+ <postCodeRegex territoryId="IO" >BBND 1ZZ</postCodeRegex>
56
+ <postCodeRegex territoryId="BN" >[A-Z]{2}[ ]?\d{4}</postCodeRegex>
57
+ <postCodeRegex territoryId="BG" >\d{4}</postCodeRegex>
58
+ <postCodeRegex territoryId="KH" >\d{5}</postCodeRegex>
59
+ <postCodeRegex territoryId="CV" >\d{4}</postCodeRegex>
60
+ <postCodeRegex territoryId="CL" >\d{7}</postCodeRegex>
61
+ <postCodeRegex territoryId="CR" >\d{4,5}|\d{3}-\d{4}</postCodeRegex>
62
+ <postCodeRegex territoryId="HR" >\d{5}</postCodeRegex>
63
+ <postCodeRegex territoryId="CY" >\d{4}</postCodeRegex>
64
+ <postCodeRegex territoryId="CZ" >\d{3}[ ]?\d{2}</postCodeRegex>
65
+ <postCodeRegex territoryId="DO" >\d{5}</postCodeRegex>
66
+ <postCodeRegex territoryId="EC" >([A-Z]\d{4}[A-Z]|(?:[A-Z]{2})?\d{6})?</postCodeRegex>
67
+ <postCodeRegex territoryId="EG" >\d{5}</postCodeRegex>
68
+ <postCodeRegex territoryId="EE" >\d{5}</postCodeRegex>
69
+ <postCodeRegex territoryId="FO" >\d{3}</postCodeRegex>
70
+ <postCodeRegex territoryId="GE" >\d{4}</postCodeRegex>
71
+ <postCodeRegex territoryId="GR" >\d{3}[ ]?\d{2}</postCodeRegex>
72
+ <postCodeRegex territoryId="GL" >39\d{2}</postCodeRegex>
73
+ <postCodeRegex territoryId="GT" >\d{5}</postCodeRegex>
74
+ <postCodeRegex territoryId="HT" >\d{4}</postCodeRegex>
75
+ <postCodeRegex territoryId="HN" >(?:\d{5})?</postCodeRegex>
76
+ <postCodeRegex territoryId="HU" >\d{4}</postCodeRegex>
77
+ <postCodeRegex territoryId="IS" >\d{3}</postCodeRegex>
78
+ <postCodeRegex territoryId="IN" >\d{6}</postCodeRegex>
79
+ <postCodeRegex territoryId="ID" >\d{5}</postCodeRegex>
80
+ <postCodeRegex territoryId="IL" >\d{5}</postCodeRegex>
81
+ <postCodeRegex territoryId="JO" >\d{5}</postCodeRegex>
82
+ <postCodeRegex territoryId="KZ" >\d{6}</postCodeRegex>
83
+ <postCodeRegex territoryId="KE" >\d{5}</postCodeRegex>
84
+ <postCodeRegex territoryId="KW" >\d{5}</postCodeRegex>
85
+ <postCodeRegex territoryId="LA" >\d{5}</postCodeRegex>
86
+ <postCodeRegex territoryId="LV" >\d{4}</postCodeRegex>
87
+ <postCodeRegex territoryId="LB" >(\d{4}([ ]?\d{4})?)?</postCodeRegex>
88
+ <postCodeRegex territoryId="LI" >(948[5-9])|(949[0-7])</postCodeRegex>
89
+ <postCodeRegex territoryId="LT" >\d{5}</postCodeRegex>
90
+ <postCodeRegex territoryId="LU" >\d{4}</postCodeRegex>
91
+ <postCodeRegex territoryId="MK" >\d{4}</postCodeRegex>
92
+ <postCodeRegex territoryId="MY" >\d{5}</postCodeRegex>
93
+ <postCodeRegex territoryId="MV" >\d{5}</postCodeRegex>
94
+ <postCodeRegex territoryId="MT" >[A-Z]{3}[ ]?\d{2,4}</postCodeRegex>
95
+ <postCodeRegex territoryId="MU" >(\d{3}[A-Z]{2}\d{3})?</postCodeRegex>
96
+ <postCodeRegex territoryId="MX" >\d{5}</postCodeRegex>
97
+ <postCodeRegex territoryId="MD" >\d{4}</postCodeRegex>
98
+ <postCodeRegex territoryId="MC" >980\d{2}</postCodeRegex>
99
+ <postCodeRegex territoryId="MA" >\d{5}</postCodeRegex>
100
+ <postCodeRegex territoryId="NP" >\d{5}</postCodeRegex>
101
+ <postCodeRegex territoryId="NZ" >\d{4}</postCodeRegex>
102
+ <postCodeRegex territoryId="NI" >((\d{4}-)?\d{3}-\d{3}(-\d{1})?)?</postCodeRegex>
103
+ <postCodeRegex territoryId="NG" >(\d{6})?</postCodeRegex>
104
+ <postCodeRegex territoryId="OM" >(PC )?\d{3}</postCodeRegex>
105
+ <postCodeRegex territoryId="PK" >\d{5}</postCodeRegex>
106
+ <postCodeRegex territoryId="PY" >\d{4}</postCodeRegex>
107
+ <postCodeRegex territoryId="PH" >\d{4}</postCodeRegex>
108
+ <postCodeRegex territoryId="PL" >\d{2}-\d{3}</postCodeRegex>
109
+ <postCodeRegex territoryId="PR" >00[679]\d{2}([ \-]\d{4})?</postCodeRegex>
110
+ <postCodeRegex territoryId="RO" >\d{6}</postCodeRegex>
111
+ <postCodeRegex territoryId="RU" >\d{6}</postCodeRegex>
112
+ <postCodeRegex territoryId="SM" >4789\d</postCodeRegex>
113
+ <postCodeRegex territoryId="SA" >\d{5}</postCodeRegex>
114
+ <postCodeRegex territoryId="SN" >\d{5}</postCodeRegex>
115
+ <postCodeRegex territoryId="SK" >\d{3}[ ]?\d{2}</postCodeRegex>
116
+ <postCodeRegex territoryId="SI" >\d{4}</postCodeRegex>
117
+ <postCodeRegex territoryId="ZA" >\d{4}</postCodeRegex>
118
+ <postCodeRegex territoryId="LK" >\d{5}</postCodeRegex>
119
+ <postCodeRegex territoryId="TJ" >\d{6}</postCodeRegex>
120
+ <postCodeRegex territoryId="TH" >\d{5}</postCodeRegex>
121
+ <postCodeRegex territoryId="TN" >\d{4}</postCodeRegex>
122
+ <postCodeRegex territoryId="TR" >\d{5}</postCodeRegex>
123
+ <postCodeRegex territoryId="TM" >\d{6}</postCodeRegex>
124
+ <postCodeRegex territoryId="UA" >\d{5}</postCodeRegex>
125
+ <postCodeRegex territoryId="UY" >\d{5}</postCodeRegex>
126
+ <postCodeRegex territoryId="UZ" >\d{6}</postCodeRegex>
127
+ <postCodeRegex territoryId="VA" >00120</postCodeRegex>
128
+ <postCodeRegex territoryId="VE" >\d{4}</postCodeRegex>
129
+ <postCodeRegex territoryId="ZM" >\d{5}</postCodeRegex>
130
+ <postCodeRegex territoryId="AS" >96799</postCodeRegex>
131
+ <postCodeRegex territoryId="CC" >6799</postCodeRegex>
132
+ <postCodeRegex territoryId="CK" >\d{4}</postCodeRegex>
133
+ <postCodeRegex territoryId="RS" >\d{6}</postCodeRegex>
134
+ <postCodeRegex territoryId="ME" >8\d{4}</postCodeRegex>
135
+ <postCodeRegex territoryId="CS" >\d{5}</postCodeRegex>
136
+ <postCodeRegex territoryId="YU" >\d{5}</postCodeRegex>
137
+ <postCodeRegex territoryId="CX" >6798</postCodeRegex>
138
+ <postCodeRegex territoryId="ET" >\d{4}</postCodeRegex>
139
+ <postCodeRegex territoryId="FK" >FIQQ 1ZZ</postCodeRegex>
140
+ <postCodeRegex territoryId="NF" >2899</postCodeRegex>
141
+ <postCodeRegex territoryId="FM" >(9694[1-4])([ \-]\d{4})?</postCodeRegex>
142
+ <postCodeRegex territoryId="GF" >9[78]3\d{2}</postCodeRegex>
143
+ <postCodeRegex territoryId="GN" >\d{3}</postCodeRegex>
144
+ <postCodeRegex territoryId="GP" >9[78][01]\d{2}</postCodeRegex>
145
+ <postCodeRegex territoryId="GS" >SIQQ 1ZZ</postCodeRegex>
146
+ <postCodeRegex territoryId="GU" >969[123]\d([ \-]\d{4})?</postCodeRegex>
147
+ <postCodeRegex territoryId="GW" >\d{4}</postCodeRegex>
148
+ <postCodeRegex territoryId="HM" >\d{4}</postCodeRegex>
149
+ <postCodeRegex territoryId="IQ" >\d{5}</postCodeRegex>
150
+ <postCodeRegex territoryId="KG" >\d{6}</postCodeRegex>
151
+ <postCodeRegex territoryId="LR" >\d{4}</postCodeRegex>
152
+ <postCodeRegex territoryId="LS" >\d{3}</postCodeRegex>
153
+ <postCodeRegex territoryId="MG" >\d{3}</postCodeRegex>
154
+ <postCodeRegex territoryId="MH" >969[67]\d([ \-]\d{4})?</postCodeRegex>
155
+ <postCodeRegex territoryId="MN" >\d{6}</postCodeRegex>
156
+ <postCodeRegex territoryId="MP" >9695[012]([ \-]\d{4})?</postCodeRegex>
157
+ <postCodeRegex territoryId="MQ" >9[78]2\d{2}</postCodeRegex>
158
+ <postCodeRegex territoryId="NC" >988\d{2}</postCodeRegex>
159
+ <postCodeRegex territoryId="NE" >\d{4}</postCodeRegex>
160
+ <postCodeRegex territoryId="VI" >008(([0-4]\d)|(5[01]))([ \-]\d{4})?</postCodeRegex>
161
+ <postCodeRegex territoryId="PF" >987\d{2}</postCodeRegex>
162
+ <postCodeRegex territoryId="PG" >\d{3}</postCodeRegex>
163
+ <postCodeRegex territoryId="PM" >9[78]5\d{2}</postCodeRegex>
164
+ <postCodeRegex territoryId="PN" >PCRN 1ZZ</postCodeRegex>
165
+ <postCodeRegex territoryId="PW" >96940</postCodeRegex>
166
+ <postCodeRegex territoryId="RE" >9[78]4\d{2}</postCodeRegex>
167
+ <postCodeRegex territoryId="SH" >(ASCN|STHL) 1ZZ</postCodeRegex>
168
+ <postCodeRegex territoryId="SJ" >\d{4}</postCodeRegex>
169
+ <postCodeRegex territoryId="SO" >\d{5}</postCodeRegex>
170
+ <postCodeRegex territoryId="SZ" >[HLMS]\d{3}</postCodeRegex>
171
+ <postCodeRegex territoryId="TC" >TKCA 1ZZ</postCodeRegex>
172
+ <postCodeRegex territoryId="WF" >986\d{2}</postCodeRegex>
173
+ <postCodeRegex territoryId="XK" >\d{5}</postCodeRegex>
174
+ <postCodeRegex territoryId="YT" >976\d{2}</postCodeRegex>
175
+ </postalCodeData>
176
+ </supplementalData>
@@ -43,7 +43,7 @@ module ValidatesZipcode
43
43
  CL: /\A\d{3}[-]?\d{4}\z/,
44
44
  HR: /\A\d{5}\z/,
45
45
  CY: /\A\d{4}\z/,
46
- CZ: /\A\d{3}[ ]?\d{2}\z/,
46
+ CZ: /\A[1-7][0-9]{2}[ ]?\d{2}\z/,
47
47
  DO: /\A\d{5}\z/,
48
48
  EC: /\A([A-Z]\d{4}[A-Z]|(?:[A-Z]{2})?\d{6})?\z/,
49
49
  EE: /\A\d{5}\z/,
@@ -176,7 +176,7 @@ module ValidatesZipcode
176
176
  GM: /\A([a-zA-Z\d\s]){3,}\z/,
177
177
  GN: /\A([a-zA-Z\d\s]){3,}\z/,
178
178
  GI: /\A(GX11 1AA)\z/,
179
- GR: /\A\d{3}([ ]\d{2})\z/,
179
+ GR: /\A\d{3}[ ]?\d{2}\z/,
180
180
  GY: /\A([a-zA-Z\d\s]){3,}\z/,
181
181
  HN: /\A(([a-zA-Z]){2}|\d{2})\d{4}\z/,
182
182
  IO: /\A\d{5}\z/,
@@ -210,7 +210,7 @@ module ValidatesZipcode
210
210
  RW: /\A([a-zA-Z\d\s]){3,}\z/,
211
211
  SC: /\A([a-zA-Z\d\s]){3,}\z/,
212
212
  SE: /\A\d{3}[ ]\d{2}\z/,
213
- SK: /\A\d{3}[ ]\d{2}\z/,
213
+ SK: /\A[089]\d{2}[ ]?\d{2}\z/,
214
214
  SL: /\A([a-zA-Z\d\s]){3,}\z/,
215
215
  SB: /\A([a-zA-Z\d\s]){3,}\z/,
216
216
  SR: /\A([a-zA-Z\d\s]){3,}\z/,
@@ -27,7 +27,7 @@ module ValidatesZipcode
27
27
  alpha2 = @country_code || record.send(@country_code_attribute)
28
28
 
29
29
  unless ValidatesZipcode::Zipcode.new(zipcode: value.to_s, country_alpha2: alpha2).valid?
30
- record.errors.add(attribute, I18n.t('errors.messages.invalid_zipcode', value: value))
30
+ record.errors.add(attribute, I18n.t('errors.messages.invalid_zipcode', value: value, default: 'Zipcode is invalid'))
31
31
  end
32
32
  end
33
33
  end
@@ -1,3 +1,3 @@
1
1
  module ValidatesZipcode
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -151,19 +151,51 @@ describe ValidatesZipcode, '#validate_each' do
151
151
  zipcode_should_be_invalid(record)
152
152
  end
153
153
  end
154
+
155
+ context 'Czech' do
156
+ it 'validates with a valid zipcode' do
157
+ ['12000', '721 00'].each do |zipcode|
158
+ record = build_record(zipcode, 'CZ')
159
+ zipcode_should_be_valid(record)
160
+ end
161
+ end
162
+
163
+ it 'does not validate with an invalid zipcode' do
164
+ record = build_record('981 32', 'CZ')
165
+ zipcode_should_be_invalid(record)
166
+ end
167
+ end
168
+
169
+ context 'Slovakia' do
170
+ it 'validates with a valid zipcode' do
171
+ ['83102', '911 05', '094 12'].each do |zipcode|
172
+ record = build_record(zipcode, 'SK')
173
+ zipcode_should_be_valid(record)
174
+ end
175
+ end
176
+
177
+ it 'does not validate with an invalid zipcode' do
178
+ record = build_record('120 00', 'SK')
179
+ zipcode_should_be_invalid(record)
180
+ end
181
+ end
154
182
  end
155
183
 
156
184
  describe ValidatesZipcode, '.valid?' do
157
185
  context "Spain" do
158
- it 'does not add errors with a valid zipcode' do
186
+ it 'is true with a valid zipcode for a given country code' do
159
187
  expect(ValidatesZipcode.valid?('93108', 'ES')).to eq(true)
160
188
  end
161
189
 
162
- it 'adds errors with an invalid Zipcode' do
190
+ it 'is false with an invalid zipcode for a given country code' do
163
191
  ['1234', '12345-12345', 'D0D0D0', 'invalid_zip'].each do |zipcode|
164
192
  expect(ValidatesZipcode.valid?(zipcode, 'ES')).to eq(false)
165
193
  end
166
194
  end
195
+
196
+ it "is true with an unknown country code - we don't have all!" do
197
+ expect(ValidatesZipcode.valid?('12345', 'ZZ')).to eq(true)
198
+ end
167
199
  end
168
200
  end
169
201
 
@@ -177,6 +209,7 @@ def zipcode_should_be_invalid(record, zipcode = "invalid_zip")
177
209
  ValidatesZipcode::Validator.new(attributes: :zipcode).validate(record)
178
210
 
179
211
  expect(record.errors.size).to eq 1
212
+ expect(record.errors.messages[:zipcode]).to include 'Zipcode is invalid'
180
213
  end
181
214
 
182
215
  def build_record(zipcode, country_alpha2)
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_zipcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Gil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-25 00:00:00.000000000 Z
11
+ date: 2016-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.6'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Adds zipcode validation methods to ActiveModel considering different
@@ -74,14 +74,16 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - .gitignore
78
- - .rspec
79
- - .travis.yml
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
80
  - CHANGELOG.md
81
+ - CODE_OF_CONDUCT.md
81
82
  - Gemfile
82
83
  - LICENSE.txt
83
84
  - README.md
84
85
  - Rakefile
86
+ - docs/postalCodeData.xml
85
87
  - lib/validates_zipcode.rb
86
88
  - lib/validates_zipcode/cldr_regex_collection.rb
87
89
  - lib/validates_zipcode/helper_methods.rb
@@ -102,17 +104,17 @@ require_paths:
102
104
  - lib
103
105
  required_ruby_version: !ruby/object:Gem::Requirement
104
106
  requirements:
105
- - - '>='
107
+ - - ">="
106
108
  - !ruby/object:Gem::Version
107
109
  version: 1.9.3
108
110
  required_rubygems_version: !ruby/object:Gem::Requirement
109
111
  requirements:
110
- - - '>='
112
+ - - ">="
111
113
  - !ruby/object:Gem::Version
112
114
  version: '0'
113
115
  requirements: []
114
116
  rubyforge_project:
115
- rubygems_version: 2.4.6
117
+ rubygems_version: 2.4.5.1
116
118
  signing_key:
117
119
  specification_version: 4
118
120
  summary: Localizable zipcode validation for Rails.