omg_validator 0.0.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardoc/checksums +14 -17
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/README.markdown +2 -7
- data/README.rdoc +2 -7
- data/doc/OmgValidator.html +31 -26
- data/doc/OmgValidator/Validators.html +30 -24
- data/doc/OmgValidator/Validators/AlphaDashValidator.html +57 -39
- data/doc/OmgValidator/Validators/{DecimalValidator.html → AlphaNumericDashValidator.html} +62 -43
- data/doc/OmgValidator/Validators/AlphaNumericValidator.html +55 -37
- data/doc/OmgValidator/Validators/AlphaValidator.html +55 -37
- data/doc/OmgValidator/Validators/EmailValidator.html +55 -37
- data/doc/OmgValidator/Validators/IpAddressValidator.html +55 -37
- data/doc/OmgValidator/Validators/PhoneNumberValidator.html +56 -38
- data/doc/OmgValidator/Validators/PostalCodeValidator.html +55 -37
- data/doc/OmgValidator/Validators/PostalOrZipCodeValidator.html +55 -37
- data/doc/OmgValidator/Validators/StrongPasswordValidator.html +56 -38
- data/doc/OmgValidator/Validators/UrlValidator.html +56 -40
- data/doc/OmgValidator/Validators/ZipCodeValidator.html +55 -36
- data/doc/_index.html +41 -74
- data/doc/class_list.html +12 -6
- data/doc/css/full_list.css +4 -2
- data/doc/css/style.css +50 -44
- data/doc/file.README.html +32 -28
- data/doc/file_list.html +12 -6
- data/doc/frames.html +20 -5
- data/doc/index.html +32 -28
- data/doc/js/app.js +52 -43
- data/doc/js/full_list.js +9 -9
- data/doc/js/jquery.js +4 -16
- data/doc/method_list.html +25 -43
- data/doc/top-level-namespace.html +25 -18
- data/lib/omg_validator.rb +1 -4
- data/lib/omg_validator/validators/alpha_dash_validator.rb +10 -6
- data/lib/omg_validator/validators/alpha_numeric_dash_validator.rb +25 -0
- data/lib/omg_validator/validators/alpha_numeric_validator.rb +8 -4
- data/lib/omg_validator/validators/alpha_validator.rb +7 -3
- data/lib/omg_validator/validators/email_validator.rb +7 -3
- data/lib/omg_validator/validators/ip_address_validator.rb +7 -3
- data/lib/omg_validator/validators/phone_number_validator.rb +7 -3
- data/lib/omg_validator/validators/postal_code_validator.rb +7 -3
- data/lib/omg_validator/validators/postal_or_zip_code_validator.rb +7 -3
- data/lib/omg_validator/validators/strong_password_validator.rb +7 -3
- data/lib/omg_validator/validators/url_validator.rb +7 -3
- data/lib/omg_validator/validators/zip_code_validator.rb +7 -3
- data/lib/omg_validator/version.rb +1 -1
- data/omg_validator-0.0.7.gem +0 -0
- data/omg_validator-0.0.8.gem +0 -0
- data/test/alpha_dash_validator_test.rb +26 -0
- data/test/alpha_numeric_dash_validator_test.rb +26 -0
- data/test/alpha_numeric_validator_test.rb +26 -0
- data/test/alpha_validator_test.rb +26 -0
- data/test/dummy/app/models/thing.rb +4 -10
- data/test/email_validator_test.rb +26 -0
- data/test/ip_address_validator_test.rb +26 -0
- data/test/support/things.rb +18 -263
- data/test/support/things.yml +109 -0
- metadata +23 -20
- data/doc/OmgValidator/Validators/DateValidator.html +0 -207
- data/doc/OmgValidator/Validators/IntegerValidator.html +0 -209
- data/doc/OmgValidator/Validators/NumericValidator.html +0 -208
- data/lib/omg_validator/validators/date_validator.rb +0 -19
- data/lib/omg_validator/validators/decimal_validator.rb +0 -21
- data/lib/omg_validator/validators/integer_validator.rb +0 -21
- data/lib/omg_validator/validators/numeric_validator.rb +0 -21
- data/test/omg_validator_test.rb +0 -247
@@ -1,208 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
-
<head>
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
-
<title>
|
7
|
-
Class: OmgValidator::Validators::NumericValidator
|
8
|
-
|
9
|
-
— Documentation by YARD 0.7.5
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
relpath = '../..';
|
19
|
-
if (relpath != '') relpath += '/';
|
20
|
-
</script>
|
21
|
-
|
22
|
-
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
23
|
-
|
24
|
-
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
25
|
-
|
26
|
-
|
27
|
-
</head>
|
28
|
-
<body>
|
29
|
-
<script type="text/javascript" charset="utf-8">
|
30
|
-
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
-
</script>
|
32
|
-
|
33
|
-
<div id="header">
|
34
|
-
<div id="menu">
|
35
|
-
|
36
|
-
<a href="../../_index.html">Index (N)</a> »
|
37
|
-
<span class='title'><span class='object_link'><a href="../../OmgValidator.html" title="OmgValidator (module)">OmgValidator</a></span></span> » <span class='title'><span class='object_link'><a href="../Validators.html" title="OmgValidator::Validators (module)">Validators</a></span></span>
|
38
|
-
»
|
39
|
-
<span class="title">NumericValidator</span>
|
40
|
-
|
41
|
-
|
42
|
-
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
43
|
-
</div>
|
44
|
-
|
45
|
-
<div id="search">
|
46
|
-
|
47
|
-
<a id="class_list_link" href="#">Class List</a>
|
48
|
-
|
49
|
-
<a id="method_list_link" href="#">Method List</a>
|
50
|
-
|
51
|
-
<a id="file_list_link" href="#">File List</a>
|
52
|
-
|
53
|
-
</div>
|
54
|
-
<div class="clear"></div>
|
55
|
-
</div>
|
56
|
-
|
57
|
-
<iframe id="search_frame"></iframe>
|
58
|
-
|
59
|
-
<div id="content"><h1>Class: OmgValidator::Validators::NumericValidator
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
</h1>
|
64
|
-
|
65
|
-
<dl class="box">
|
66
|
-
|
67
|
-
<dt class="r1">Inherits:</dt>
|
68
|
-
<dd class="r1">
|
69
|
-
<span class="inheritName">ActiveModel::EachValidator</span>
|
70
|
-
|
71
|
-
<ul class="fullTree">
|
72
|
-
<li>Object</li>
|
73
|
-
|
74
|
-
<li class="next">ActiveModel::EachValidator</li>
|
75
|
-
|
76
|
-
<li class="next">OmgValidator::Validators::NumericValidator</li>
|
77
|
-
|
78
|
-
</ul>
|
79
|
-
<a href="#" class="inheritanceTree">show all</a>
|
80
|
-
|
81
|
-
</dd>
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
<dt class="r2 last">Defined in:</dt>
|
92
|
-
<dd class="r2 last">lib/omg_validator/validators/numeric_validator.rb</dd>
|
93
|
-
|
94
|
-
</dl>
|
95
|
-
<div class="clear"></div>
|
96
|
-
|
97
|
-
<h2>Overview</h2><div class="docstring">
|
98
|
-
<div class="discussion">
|
99
|
-
<p>
|
100
|
-
Checks whether input is a valid number
|
101
|
-
</p>
|
102
|
-
<p>
|
103
|
-
validates :count, number: true
|
104
|
-
</p>
|
105
|
-
<p>
|
106
|
-
matches: 123, 523.12, -23, -23.12 does not match: six, 23.23.12, 1,000
|
107
|
-
</p>
|
108
|
-
|
109
|
-
|
110
|
-
</div>
|
111
|
-
</div>
|
112
|
-
<div class="tags">
|
113
|
-
|
114
|
-
|
115
|
-
</div>
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
<h2>
|
124
|
-
Instance Method Summary
|
125
|
-
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
126
|
-
</h2>
|
127
|
-
|
128
|
-
<ul class="summary">
|
129
|
-
|
130
|
-
<li class="public ">
|
131
|
-
<span class="summary_signature">
|
132
|
-
|
133
|
-
<a href="#validate_each-instance_method" title="#validate_each (instance method)">- (Object) <strong>validate_each</strong>(record, attribute, value) </a>
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
</span>
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
147
|
-
|
148
|
-
</li>
|
149
|
-
|
150
|
-
|
151
|
-
</ul>
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
<div id="instance_method_details" class="method_details_list">
|
158
|
-
<h2>Instance Method Details</h2>
|
159
|
-
|
160
|
-
|
161
|
-
<div class="method_details first">
|
162
|
-
<p class="signature first" id="validate_each-instance_method">
|
163
|
-
|
164
|
-
- (<tt>Object</tt>) <strong>validate_each</strong>(record, attribute, value)
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
</p><table class="source_code">
|
169
|
-
<tr>
|
170
|
-
<td>
|
171
|
-
<pre class="lines">
|
172
|
-
|
173
|
-
|
174
|
-
10
|
175
|
-
11
|
176
|
-
12
|
177
|
-
13
|
178
|
-
14
|
179
|
-
15
|
180
|
-
16</pre>
|
181
|
-
</td>
|
182
|
-
<td>
|
183
|
-
<pre class="code"><span class="info file"># File 'lib/omg_validator/validators/numeric_validator.rb', line 10</span>
|
184
|
-
|
185
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_validate_each'>validate_each</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
186
|
-
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
187
|
-
<span class='id identifier rubyid_reg'>reg</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^[\-+]?[0-9]*\.?[0-9]+$</span><span class='regexp_end'>/</span></span>
|
188
|
-
<span class='kw'>unless</span> <span class='id identifier rubyid_reg'>reg</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
189
|
-
<span class='id identifier rubyid_record'>record</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='lbracket'>[</span><span class='id identifier rubyid_attribute'>attribute</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>must be a valid number</span><span class='tstring_end'>"</span></span>
|
190
|
-
<span class='kw'>end</span>
|
191
|
-
<span class='kw'>end</span></pre>
|
192
|
-
</td>
|
193
|
-
</tr>
|
194
|
-
</table>
|
195
|
-
</div>
|
196
|
-
|
197
|
-
</div>
|
198
|
-
|
199
|
-
</div>
|
200
|
-
|
201
|
-
<div id="footer">
|
202
|
-
Generated on Thu Apr 5 00:05:42 2012 by
|
203
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
204
|
-
0.7.5 (ruby-1.9.2).
|
205
|
-
</div>
|
206
|
-
|
207
|
-
</body>
|
208
|
-
</html>
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module OmgValidator
|
2
|
-
module Validators
|
3
|
-
# Checks whether input is a valid date
|
4
|
-
#
|
5
|
-
# validates :posting_date, date: true
|
6
|
-
class DateValidator < ActiveModel::EachValidator
|
7
|
-
def validate_each(record, attribute, value)
|
8
|
-
return nil if value.blank?
|
9
|
-
begin
|
10
|
-
Date.parse(value)
|
11
|
-
rescue
|
12
|
-
record.errors[attribute] = "must be a valid date"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
ActiveModel::Validations::DateValidator = OmgValidator::Validators::AlphaValidator
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module OmgValidator
|
2
|
-
module Validators
|
3
|
-
# Checks whether input is a valid floating point number
|
4
|
-
#
|
5
|
-
# validates :total_value, decimal: true
|
6
|
-
#
|
7
|
-
# matches: 10.00, -23.12, 9.99, 1.9002302
|
8
|
-
# does not match: 123, 99, -23, 1,000
|
9
|
-
class DecimalValidator < ActiveModel::EachValidator
|
10
|
-
def validate_each(record, attribute, value)
|
11
|
-
return nil if value.blank?
|
12
|
-
reg = /^[\-+]?[0-9]+\.[0-9]+$/
|
13
|
-
unless reg.match(value)
|
14
|
-
record.errors[attribute] = "must be a valid floating point number"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
ActiveModel::Validations::DecimalValidator = OmgValidator::Validators::DecimalValidator
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module OmgValidator
|
2
|
-
module Validators
|
3
|
-
# Checks whether input is a valid integer
|
4
|
-
#
|
5
|
-
# validates :count, integer: true
|
6
|
-
#
|
7
|
-
# matches: 10, 20, 2323, -20, 10000000,
|
8
|
-
# does not match: 10.50, -22.21, 1,000, ten
|
9
|
-
class IntegerValidator < ActiveModel::EachValidator
|
10
|
-
def validate_each(record, attribute, value)
|
11
|
-
return nil if value.blank?
|
12
|
-
reg = /^[\-+]?[0-9]+$/
|
13
|
-
unless reg.match(value)
|
14
|
-
record.errors[attribute] = "must be a valid integer"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
ActiveModel::Validations::IntegerValidator = OmgValidator::Validators::IntegerValidator
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module OmgValidator
|
2
|
-
module Validators
|
3
|
-
# Checks whether input is a valid number
|
4
|
-
#
|
5
|
-
# validates :count, number: true
|
6
|
-
#
|
7
|
-
# matches: 123, 523.12, -23, -23.12
|
8
|
-
# does not match: six, 23.23.12, 1,000
|
9
|
-
class NumericValidator < ActiveModel::EachValidator
|
10
|
-
def validate_each(record, attribute, value)
|
11
|
-
return nil if value.blank?
|
12
|
-
reg = /^[\-+]?[0-9]*\.?[0-9]+$/
|
13
|
-
unless reg.match(value)
|
14
|
-
record.errors[attribute] = "must be a valid number"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
ActiveModel::Validations::NumericValidator = OmgValidator::Validators::NumericValidator
|
data/test/omg_validator_test.rb
DELETED
@@ -1,247 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class OmgValidatorTest < ActiveSupport::TestCase
|
4
|
-
def setup
|
5
|
-
@thing = Thing.new
|
6
|
-
end
|
7
|
-
|
8
|
-
def teardown
|
9
|
-
@thing = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
test "truth" do
|
13
|
-
assert_kind_of Module, OmgValidator
|
14
|
-
end
|
15
|
-
|
16
|
-
# alpha
|
17
|
-
test "thing should be invalid if alpha contains non-alpha characters" do
|
18
|
-
Things.alphas[:invalid].each do |alpha|
|
19
|
-
@thing.alpha = alpha
|
20
|
-
assert !@thing.valid?, "#{alpha} - #{@thing.errors.full_messages.join("\n")}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
test "thing should be valid if alpha contains only alpha characters" do
|
25
|
-
Things.alphas[:valid].each do |alpha|
|
26
|
-
@thing.alpha = alpha
|
27
|
-
assert @thing.valid?, "#{alpha} - #{@thing.errors.full_messages.join("\n")}"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# alpha numeric
|
32
|
-
test "thing should be invalid if alpha_numeric contains non-alpha-numeric characters" do
|
33
|
-
Things.alpha_numerics[:invalid].each do |alpha_numeric|
|
34
|
-
@thing.alpha_numeric = alpha_numeric
|
35
|
-
assert !@thing.valid?, "#{alpha_numeric} - #{@thing.errors.full_messages.join("\n")}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
test "thing should be valid if alpha_numeric contains only alpha-numeric characters" do
|
40
|
-
Things.alpha_numerics[:valid].each do |alpha_numeric|
|
41
|
-
@thing.alpha_numeric = alpha_numeric
|
42
|
-
assert @thing.valid?, "#{alpha_numeric} - #{@thing.errors.full_messages.join("\n")}"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# alpha dash
|
47
|
-
test "thing should be invalid if alpha_dash contains non-alpha-numeric-dashes characters" do
|
48
|
-
Things.alpha_dashes[:invalid].each do |alpha_dash|
|
49
|
-
@thing.alpha_dash = alpha_dash
|
50
|
-
assert !@thing.valid?, "#{alpha_dash} - #{@thing.errors.full_messages.join("\n")}"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
test "thing should be valid if alpha_dash contains only alpha-numeric-dashes characters" do
|
55
|
-
Things.alpha_dashes[:valid].each do |alpha_dash|
|
56
|
-
@thing.alpha_dash = alpha_dash
|
57
|
-
assert @thing.valid? "#{alpha_dash} - #{@thing.errors.full_messages.join("\n")}"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
test "thing should be valid if alpha_dash contains only alpha or dash characters" do
|
62
|
-
Things.alpha_dashes[:valid].each do |alpha_dash|
|
63
|
-
@thing.alpha_dash = alpha_dash
|
64
|
-
assert @thing.valid?, "#{alpha_dash} - #{@thing.errors.full_messages.join("\n")}"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# zip code
|
69
|
-
test "thing should be invalid if zip_code is not a valid zip_code" do
|
70
|
-
Things.zip_codes[:invalid].each do |zip|
|
71
|
-
@thing.zip_code = zip
|
72
|
-
assert !@thing.valid?, "#{zip} - #{@thing.errors.full_messages.join("\n")}"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
test "thing should be valid if zip_code is a valid zip code" do
|
77
|
-
Things.zip_codes[:valid].each do |zip|
|
78
|
-
@thing.zip_code = zip
|
79
|
-
assert @thing.valid?, "#{zip} - #{@thing.errors.full_messages.join("\n")}"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
# postal or zip code
|
84
|
-
test "thing should be invalid if postal_or_zip_code is not a valid postal or zip code" do
|
85
|
-
Things.postal_codes[:invalid].concat(Things.zip_codes[:invalid]).each do |zip_or_postal|
|
86
|
-
@thing.postal_or_zip_code = zip_or_postal
|
87
|
-
assert !@thing.valid?, "#{zip_or_postal} - #{@thing.errors.full_messages.join("\n")}"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
test "thing should be valid if postal_or_zip_code is a valid postal or zip code" do
|
92
|
-
Things.postal_codes[:valid].concat(Things.zip_codes[:valid]).each do |zip_or_postal|
|
93
|
-
@thing.postal_or_zip_code = zip_or_postal
|
94
|
-
assert @thing.valid?, "#{zip_or_postal} - #{@thing.errors.full_messages.join("\n")}"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# postal code
|
99
|
-
test "thing should be valid if postal_code is a valid postal code" do
|
100
|
-
Things.postal_codes[:valid].each do |code|
|
101
|
-
@thing.postal_code = code
|
102
|
-
assert @thing.valid?, "#{code} - #{@thing.errors.full_messages.join("\n")}"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
test "thing should be invalid if postal_code is not a valid postal code" do
|
107
|
-
Things.postal_codes[:invalid].each do |code|
|
108
|
-
@thing.postal_code = code
|
109
|
-
assert !@thing.valid?, "#{code} - #{@thing.errors.full_messages.join("\n")}"
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
# decimals
|
114
|
-
test "thing should be valid if decimal is a valid decimal" do
|
115
|
-
Things.decimals[:valid].each do |decimal|
|
116
|
-
@thing.decimal = decimal
|
117
|
-
assert @thing.valid?, "#{decimal} - #{@thing.errors.full_messages.join("\n")}"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
test "thing should be invalid if decimal is not a valid decimal" do
|
122
|
-
Things.decimals[:invalid].each do |decimal|
|
123
|
-
@thing.decimal = decimal
|
124
|
-
assert !@thing.valid?, "#{decimal} - #{@thing.errors.full_messages.join("\n")}"
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
# integer
|
129
|
-
test "thing should be valid if integer is a valid integer" do
|
130
|
-
Things.integers[:valid].each do |integer|
|
131
|
-
@thing.integer = integer
|
132
|
-
assert @thing.valid?, "#{integer} - #{@thing.errors.full_messages.join("\n")}"
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
test "thing should be invalid if integer is not a valid integer" do
|
137
|
-
Things.integers[:invalid].each do |integer|
|
138
|
-
@thing.integer = integer
|
139
|
-
assert !@thing.valid?, "#{integer} - #{@thing.errors.full_messages.join("\n")}"
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
# numeric
|
144
|
-
test "thing should be valid if numeric is a valid numeric" do
|
145
|
-
Things.numeric[:valid].each do |numeric|
|
146
|
-
@thing.numeric = numeric
|
147
|
-
assert @thing.valid?, "#{numeric} - #{@thing.errors.full_messages.join("\n")}"
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
test "thing should be invalid if numeric is not a valid numeric" do
|
152
|
-
Things.numeric[:invalid].each do |numeric|
|
153
|
-
@thing.numeric = numeric
|
154
|
-
assert !@thing.valid?, "#{numeric} - #{@thing.errors.full_messages.join("\n")}"
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
# email
|
159
|
-
test "thing should be valid if email is a valid email" do
|
160
|
-
Things.emails[:valid].each do |email|
|
161
|
-
@thing.email = email
|
162
|
-
assert @thing.valid?, "#{email} - #{@thing.errors.full_messages.join("\n")}"
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
test "thing should be invalid if email is not a valid email" do
|
167
|
-
Things.emails[:invalid].each do |email|
|
168
|
-
@thing.email = email
|
169
|
-
assert !@thing.valid?, "#{email} - #{@thing.errors.full_messages.join("\n")}"
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
# ip address
|
174
|
-
test "thing should be valid if ip_address is a valid ip address" do
|
175
|
-
Things.ip_addresses[:valid].each do |ip|
|
176
|
-
@thing.ip_address = ip
|
177
|
-
assert @thing.valid?, "#{ip} - #{@thing.errors.full_messages.join("\n")}"
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
test "thing should be invalid if ip_address is not a valid ip address" do
|
182
|
-
Things.ip_addresses[:invalid].each do |ip|
|
183
|
-
@thing.ip_address = ip
|
184
|
-
assert !@thing.valid?, "#{ip} - #{@thing.errors.full_messages.join("\n")}"
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
# url
|
189
|
-
test "thing should be valid if url is a valid url" do
|
190
|
-
Things.urls[:valid].each do |url|
|
191
|
-
@thing.url = url
|
192
|
-
assert @thing.valid?, "#{url} - #{@thing.errors.full_messages.join("\n")}"
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
test "thing should be invalid if url is not a valid url" do
|
197
|
-
Things.urls[:invalid].each do |url|
|
198
|
-
@thing.url = url
|
199
|
-
assert !@thing.valid?, "#{url} - #{@thing.errors.full_messages.join("\n")}"
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
# phone number
|
204
|
-
test "thing should be valid if phone is a valid phone number" do
|
205
|
-
Things.phone_numbers[:valid].each do |phone|
|
206
|
-
@thing.phone = phone
|
207
|
-
assert @thing.valid?, "#{phone} - #{@thing.errors.full_messages.join("\n")}"
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
test "thing should be invalid if phone is not a valid phone number" do
|
212
|
-
Things.phone_numbers[:invalid].each do |phone|
|
213
|
-
@thing.phone = phone
|
214
|
-
assert !@thing.valid?, "#{phone} - #{@thing.errors.full_messages.join("\n")}"
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
# strong password
|
219
|
-
test "thing should be valid if password is a valid strong password" do
|
220
|
-
Things.strong_passwords[:valid].each do |password|
|
221
|
-
@thing.password = password
|
222
|
-
assert @thing.valid?, "#{password} - #{@thing.errors.full_messages.join("\n")}"
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
test "thing should be invalid if password is not a valid strong password" do
|
227
|
-
Things.strong_passwords[:invalid].each do |password|
|
228
|
-
@thing.password = password
|
229
|
-
assert !@thing.valid?, "#{password} - #{@thing.errors.full_messages.join("\n")}"
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
# date
|
234
|
-
test "thing should be valid if date is a valid date" do
|
235
|
-
Things.dates[:valid].each do |date|
|
236
|
-
@thing.date = date
|
237
|
-
assert @thing.valid?, "#{date} - #{@thing.errors.full_messages.join("\n")}"
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
test "thing should be invalid if date is not a valid date" do
|
242
|
-
Things.dates[:invalid].each do |date|
|
243
|
-
@thing.date = date
|
244
|
-
assert !@thing.valid?, "#{date} - #{@thing.errors.full_messages.join("\n")}"
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|