schemacop 1.0.2 → 2.0.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 +4 -4
- data/.gitignore +2 -1
- data/.rubocop.yml +59 -1
- data/CHANGELOG.md +10 -0
- data/README.md +389 -199
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/doc/Schemacop.html +41 -130
- data/doc/Schemacop/ArrayValidator.html +329 -0
- data/doc/Schemacop/BooleanValidator.html +145 -0
- data/doc/Schemacop/Collector.html +535 -0
- data/doc/Schemacop/Exceptions.html +39 -39
- data/doc/Schemacop/Exceptions/InvalidSchemaError.html +124 -0
- data/doc/Schemacop/Exceptions/ValidationError.html +124 -0
- data/doc/Schemacop/FieldNode.html +409 -0
- data/doc/Schemacop/FloatValidator.html +158 -0
- data/doc/Schemacop/HashValidator.html +263 -0
- data/doc/Schemacop/IntegerValidator.html +158 -0
- data/doc/Schemacop/NilValidator.html +145 -0
- data/doc/Schemacop/Node.html +1426 -0
- data/doc/Schemacop/NodeResolver.html +242 -0
- data/doc/Schemacop/NodeSupportingField.html +590 -0
- data/doc/Schemacop/NodeSupportingType.html +614 -0
- data/doc/Schemacop/NodeWithBlock.html +289 -0
- data/doc/Schemacop/NumberValidator.html +232 -0
- data/doc/Schemacop/ObjectValidator.html +288 -0
- data/doc/Schemacop/RootNode.html +171 -0
- data/doc/Schemacop/Schema.html +697 -0
- data/doc/Schemacop/StringValidator.html +295 -0
- data/doc/ScopedEnv.html +351 -0
- data/doc/_index.html +190 -47
- data/doc/class_list.html +24 -31
- data/doc/css/full_list.css +32 -31
- data/doc/css/style.css +244 -91
- data/doc/file.README.html +428 -232
- data/doc/file_list.html +26 -30
- data/doc/frames.html +7 -16
- data/doc/index.html +428 -232
- data/doc/inheritance.graphml +524 -0
- data/doc/inheritance.pdf +825 -0
- data/doc/js/app.js +106 -77
- data/doc/js/full_list.js +170 -135
- data/doc/method_list.html +494 -38
- data/doc/top-level-namespace.html +36 -36
- data/lib/schemacop.rb +22 -7
- data/lib/schemacop/collector.rb +34 -0
- data/lib/schemacop/exceptions.rb +2 -8
- data/lib/schemacop/field_node.rb +26 -0
- data/lib/schemacop/node.rb +127 -0
- data/lib/schemacop/node_resolver.rb +14 -0
- data/lib/schemacop/node_supporting_field.rb +62 -0
- data/lib/schemacop/node_supporting_type.rb +112 -0
- data/lib/schemacop/node_with_block.rb +16 -0
- data/lib/schemacop/root_node.rb +4 -0
- data/lib/schemacop/schema.rb +61 -0
- data/lib/schemacop/scoped_env.rb +18 -0
- data/lib/schemacop/validator/array_validator.rb +30 -0
- data/lib/schemacop/validator/boolean_validator.rb +5 -0
- data/lib/schemacop/validator/float_validator.rb +5 -0
- data/lib/schemacop/validator/hash_validator.rb +18 -0
- data/lib/schemacop/validator/integer_validator.rb +5 -0
- data/lib/schemacop/validator/nil_validator.rb +5 -0
- data/lib/schemacop/validator/number_validator.rb +19 -0
- data/lib/schemacop/validator/object_validator.rb +21 -0
- data/lib/schemacop/validator/string_validator.rb +37 -0
- data/schemacop.gemspec +7 -5
- data/test/custom_check_test.rb +86 -0
- data/test/custom_if_test.rb +95 -0
- data/test/nil_dis_allow_test.rb +41 -0
- data/test/short_forms_test.rb +316 -0
- data/test/test_helper.rb +6 -0
- data/test/types_test.rb +83 -0
- data/test/validator_array_test.rb +97 -0
- data/test/validator_boolean_test.rb +15 -0
- data/test/validator_float_test.rb +57 -0
- data/test/validator_hash_test.rb +71 -0
- data/test/validator_integer_test.rb +46 -0
- data/test/validator_nil_test.rb +13 -0
- data/test/validator_number_test.rb +60 -0
- data/test/validator_object_test.rb +87 -0
- data/test/validator_string_test.rb +76 -0
- metadata +78 -14
- data/doc/Schemacop/Exceptions/Base.html +0 -127
- data/doc/Schemacop/Exceptions/InvalidSchema.html +0 -141
- data/doc/Schemacop/Exceptions/Validation.html +0 -142
- data/doc/Schemacop/MethodValidation.html +0 -120
- data/doc/Schemacop/MethodValidation/ClassMethods.html +0 -196
- data/doc/Schemacop/Validator.html +0 -254
- data/lib/schemacop/validator.rb +0 -145
- data/test/schemacop_validator_test.rb +0 -257
data/Rakefile
CHANGED
@@ -7,6 +7,8 @@ task :gemspec do
|
|
7
7
|
Schemacop validates ruby structures consisting of nested hashes and arrays
|
8
8
|
against simple schema definitions.
|
9
9
|
)
|
10
|
+
spec.license = 'MIT'
|
11
|
+
spec.homepage = 'https://github.com/sitrox/schemacop'
|
10
12
|
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
11
13
|
spec.executables = []
|
12
14
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/doc/Schemacop.html
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
4
3
|
<head>
|
5
|
-
<meta
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
6
|
<title>
|
7
7
|
Module: Schemacop
|
8
8
|
|
9
|
-
— Documentation by YARD 0.
|
9
|
+
— Documentation by YARD 0.9.9
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -15,9 +15,8 @@
|
|
15
15
|
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
16
|
|
17
17
|
<script type="text/javascript" charset="utf-8">
|
18
|
-
|
18
|
+
pathId = "Schemacop";
|
19
19
|
relpath = '';
|
20
|
-
framesUrl = "frames.html#!Schemacop.html";
|
21
20
|
</script>
|
22
21
|
|
23
22
|
|
@@ -28,73 +27,73 @@
|
|
28
27
|
|
29
28
|
</head>
|
30
29
|
<body>
|
31
|
-
<div
|
32
|
-
<
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
33
38
|
|
34
39
|
<a href="_index.html">Index (S)</a> »
|
35
40
|
|
36
41
|
|
37
42
|
<span class="title">Schemacop</span>
|
38
43
|
|
39
|
-
|
40
|
-
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
44
|
</div>
|
42
45
|
|
43
|
-
|
46
|
+
<div id="search">
|
44
47
|
|
45
48
|
<a class="full_list_link" id="class_list_link"
|
46
49
|
href="class_list.html">
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
</a>
|
54
|
-
|
55
|
-
<a class="full_list_link" id="file_list_link"
|
56
|
-
href="file_list.html">
|
57
|
-
File List
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
58
56
|
</a>
|
59
57
|
|
60
58
|
</div>
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
<iframe id="search_frame"></iframe>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
65
61
|
|
66
|
-
|
62
|
+
<div id="content"><h1>Module: Schemacop
|
67
63
|
|
68
64
|
|
69
65
|
|
70
66
|
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
71
69
|
|
72
|
-
<dl class="box">
|
73
70
|
|
74
71
|
|
75
|
-
|
76
72
|
|
77
|
-
|
78
73
|
|
79
74
|
|
75
|
+
|
80
76
|
|
81
|
-
|
82
|
-
|
83
|
-
|
77
|
+
|
78
|
+
|
79
|
+
<dl>
|
80
|
+
<dt>Defined in:</dt>
|
81
|
+
<dd>lib/schemacop.rb<span class="defines">,<br />
|
82
|
+
lib/schemacop/node.rb,<br /> lib/schemacop/schema.rb,<br /> lib/schemacop/collector.rb,<br /> lib/schemacop/root_node.rb,<br /> lib/schemacop/field_node.rb,<br /> lib/schemacop/node_resolver.rb,<br /> lib/schemacop/node_with_block.rb,<br /> lib/schemacop/node_supporting_type.rb,<br /> lib/schemacop/node_supporting_field.rb,<br /> lib/schemacop/validator/nil_validator.rb,<br /> lib/schemacop/validator/hash_validator.rb,<br /> lib/schemacop/validator/array_validator.rb,<br /> lib/schemacop/validator/float_validator.rb,<br /> lib/schemacop/validator/number_validator.rb,<br /> lib/schemacop/validator/object_validator.rb,<br /> lib/schemacop/validator/string_validator.rb,<br /> lib/schemacop/validator/boolean_validator.rb,<br /> lib/schemacop/validator/integer_validator.rb</span>
|
84
83
|
</dd>
|
84
|
+
</dl>
|
85
85
|
|
86
|
-
</
|
87
|
-
<div class="clear"></div>
|
86
|
+
</div>
|
88
87
|
|
89
88
|
<h2>Defined Under Namespace</h2>
|
90
89
|
<p class="children">
|
91
90
|
|
92
91
|
|
93
|
-
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Schemacop/Exceptions.html" title="Schemacop::Exceptions (module)">Exceptions</a></span
|
92
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Schemacop/Exceptions.html" title="Schemacop::Exceptions (module)">Exceptions</a></span>
|
94
93
|
|
95
94
|
|
96
95
|
|
97
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Schemacop/
|
96
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Schemacop/ArrayValidator.html" title="Schemacop::ArrayValidator (class)">ArrayValidator</a></span>, <span class='object_link'><a href="Schemacop/BooleanValidator.html" title="Schemacop::BooleanValidator (class)">BooleanValidator</a></span>, <span class='object_link'><a href="Schemacop/Collector.html" title="Schemacop::Collector (class)">Collector</a></span>, <span class='object_link'><a href="Schemacop/FieldNode.html" title="Schemacop::FieldNode (class)">FieldNode</a></span>, <span class='object_link'><a href="Schemacop/FloatValidator.html" title="Schemacop::FloatValidator (class)">FloatValidator</a></span>, <span class='object_link'><a href="Schemacop/HashValidator.html" title="Schemacop::HashValidator (class)">HashValidator</a></span>, <span class='object_link'><a href="Schemacop/IntegerValidator.html" title="Schemacop::IntegerValidator (class)">IntegerValidator</a></span>, <span class='object_link'><a href="Schemacop/NilValidator.html" title="Schemacop::NilValidator (class)">NilValidator</a></span>, <span class='object_link'><a href="Schemacop/Node.html" title="Schemacop::Node (class)">Node</a></span>, <span class='object_link'><a href="Schemacop/NodeResolver.html" title="Schemacop::NodeResolver (class)">NodeResolver</a></span>, <span class='object_link'><a href="Schemacop/NodeSupportingField.html" title="Schemacop::NodeSupportingField (class)">NodeSupportingField</a></span>, <span class='object_link'><a href="Schemacop/NodeSupportingType.html" title="Schemacop::NodeSupportingType (class)">NodeSupportingType</a></span>, <span class='object_link'><a href="Schemacop/NodeWithBlock.html" title="Schemacop::NodeWithBlock (class)">NodeWithBlock</a></span>, <span class='object_link'><a href="Schemacop/NumberValidator.html" title="Schemacop::NumberValidator (class)">NumberValidator</a></span>, <span class='object_link'><a href="Schemacop/ObjectValidator.html" title="Schemacop::ObjectValidator (class)">ObjectValidator</a></span>, <span class='object_link'><a href="Schemacop/RootNode.html" title="Schemacop::RootNode (class)">RootNode</a></span>, <span class='object_link'><a href="Schemacop/Schema.html" title="Schemacop::Schema (class)">Schema</a></span>, <span class='object_link'><a href="Schemacop/StringValidator.html" title="Schemacop::StringValidator (class)">StringValidator</a></span>
|
98
97
|
|
99
98
|
|
100
99
|
</p>
|
@@ -105,104 +104,16 @@
|
|
105
104
|
|
106
105
|
|
107
106
|
|
108
|
-
|
109
|
-
<h2>
|
110
|
-
Class Method Summary
|
111
|
-
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
112
|
-
</h2>
|
113
107
|
|
114
|
-
<ul class="summary">
|
115
|
-
|
116
|
-
<li class="public ">
|
117
|
-
<span class="summary_signature">
|
118
|
-
|
119
|
-
<a href="#validate%21-class_method" title="validate! (class method)">+ (Object) <strong>validate!</strong>(schema, data) </a>
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
</span>
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
108
|
|
132
|
-
|
133
|
-
<span class="summary_desc"><div class='inline'><p><p>Validates <code>data</code> against <code>schema</code> and throws an exception on missmatch.</p>
|
134
|
-
</p>
|
135
|
-
</div></span>
|
136
|
-
|
137
|
-
</li>
|
138
|
-
|
139
|
-
|
140
|
-
</ul>
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
<div id="class_method_details" class="method_details_list">
|
146
|
-
<h2>Class Method Details</h2>
|
147
|
-
|
148
|
-
|
149
|
-
<div class="method_details first">
|
150
|
-
<h3 class="signature first" id="validate!-class_method">
|
151
|
-
|
152
|
-
+ (<tt>Object</tt>) <strong>validate!</strong>(schema, data)
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
</h3><div class="docstring">
|
159
|
-
<div class="discussion">
|
160
|
-
<p><p>Validates <code>data</code> against <code>schema</code> and throws an exception on missmatch.</p>
|
161
|
-
</p>
|
162
|
-
|
163
|
-
|
164
|
-
</div>
|
165
|
-
</div>
|
166
|
-
<div class="tags">
|
167
|
-
|
168
|
-
|
169
|
-
<p class="tag_title">See Also:</p>
|
170
|
-
<ul class="see">
|
171
|
-
|
172
|
-
<li><span class='object_link'><a href="Schemacop/Validator.html#validate%21-class_method" title="Schemacop::Validator.validate! (method)">Schemacop::Validator.validate!</a></span></li>
|
173
|
-
|
174
|
-
</ul>
|
175
|
-
|
176
|
-
</div><table class="source_code">
|
177
|
-
<tr>
|
178
|
-
<td>
|
179
|
-
<pre class="lines">
|
180
|
-
|
181
|
-
|
182
|
-
4
|
183
|
-
5
|
184
|
-
6</pre>
|
185
|
-
</td>
|
186
|
-
<td>
|
187
|
-
<pre class="code"><span class="info file"># File 'lib/schemacop.rb', line 4</span>
|
188
|
-
|
189
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_validate!'>validate!</span><span class='lparen'>(</span><span class='id identifier rubyid_schema'>schema</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
|
190
|
-
<span class='const'>Validator</span><span class='period'>.</span><span class='id identifier rubyid_validate!'>validate!</span><span class='lparen'>(</span><span class='id identifier rubyid_schema'>schema</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
|
191
|
-
<span class='kw'>end</span></pre>
|
192
|
-
</td>
|
193
|
-
</tr>
|
194
|
-
</table>
|
195
109
|
</div>
|
196
|
-
|
197
|
-
</div>
|
198
110
|
|
199
|
-
|
200
|
-
|
201
|
-
<div id="footer">
|
202
|
-
Generated on Thu Oct 6 19:45:02 2016 by
|
111
|
+
<div id="footer">
|
112
|
+
Generated on Mon May 15 17:46:05 2017 by
|
203
113
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
204
|
-
0.
|
114
|
+
0.9.9 (ruby-2.3.1).
|
205
115
|
</div>
|
206
116
|
|
117
|
+
</div>
|
207
118
|
</body>
|
208
119
|
</html>
|
@@ -0,0 +1,329 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Schemacop::ArrayValidator
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.9
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Schemacop::ArrayValidator";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (A)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Schemacop.html" title="Schemacop (module)">Schemacop</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">ArrayValidator</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Schemacop::ArrayValidator
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName"><span class='object_link'><a href="NodeSupportingType.html" title="Schemacop::NodeSupportingType (class)">NodeSupportingType</a></span></span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next"><span class='object_link'><a href="Node.html" title="Schemacop::Node (class)">Node</a></span></li>
|
78
|
+
|
79
|
+
<li class="next"><span class='object_link'><a href="NodeWithBlock.html" title="Schemacop::NodeWithBlock (class)">NodeWithBlock</a></span></li>
|
80
|
+
|
81
|
+
<li class="next"><span class='object_link'><a href="NodeSupportingType.html" title="Schemacop::NodeSupportingType (class)">NodeSupportingType</a></span></li>
|
82
|
+
|
83
|
+
<li class="next">Schemacop::ArrayValidator</li>
|
84
|
+
|
85
|
+
</ul>
|
86
|
+
<a href="#" class="inheritanceTree">show all</a>
|
87
|
+
|
88
|
+
</dd>
|
89
|
+
</dl>
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
<dl>
|
102
|
+
<dt>Defined in:</dt>
|
103
|
+
<dd>lib/schemacop/validator/array_validator.rb</dd>
|
104
|
+
</dl>
|
105
|
+
|
106
|
+
</div>
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
<h2>Instance Attribute Summary</h2>
|
115
|
+
|
116
|
+
<h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Node.html" title="Schemacop::Node (class)">Node</a></span></h3>
|
117
|
+
<p class="inherited"><span class='object_link'><a href="Node.html#options-instance_method" title="Schemacop::Node#options (method)">#options</a></span></p>
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<h2>
|
122
|
+
Instance Method Summary
|
123
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
124
|
+
</h2>
|
125
|
+
|
126
|
+
<ul class="summary">
|
127
|
+
|
128
|
+
<li class="public ">
|
129
|
+
<span class="summary_signature">
|
130
|
+
|
131
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(*args) ⇒ ArrayValidator </a>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
</span>
|
136
|
+
|
137
|
+
|
138
|
+
<span class="note title constructor">constructor</span>
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
<span class="summary_desc"><div class='inline'><p>A new instance of ArrayValidator.</p>
|
148
|
+
</div></span>
|
149
|
+
|
150
|
+
</li>
|
151
|
+
|
152
|
+
|
153
|
+
<li class="public ">
|
154
|
+
<span class="summary_signature">
|
155
|
+
|
156
|
+
<a href="#validate-instance_method" title="#validate (instance method)">#<strong>validate</strong>(data, collector) ⇒ Object </a>
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
</span>
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
171
|
+
|
172
|
+
</li>
|
173
|
+
|
174
|
+
|
175
|
+
</ul>
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="NodeSupportingType.html" title="Schemacop::NodeSupportingType (class)">NodeSupportingType</a></span></h3>
|
188
|
+
<p class="inherited"><span class='object_link'><a href="NodeSupportingType.html#build-class_method" title="Schemacop::NodeSupportingType.build (method)">build</a></span>, <span class='object_link'><a href="NodeSupportingType.html#exec_block-instance_method" title="Schemacop::NodeSupportingType#exec_block (method)">#exec_block</a></span>, <span class='object_link'><a href="NodeSupportingType.html#type-instance_method" title="Schemacop::NodeSupportingType#type (method)">#type</a></span></p>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="NodeWithBlock.html" title="Schemacop::NodeWithBlock (class)">NodeWithBlock</a></span></h3>
|
199
|
+
<p class="inherited"><span class='object_link'><a href="NodeWithBlock.html#block_method-class_method" title="Schemacop::NodeWithBlock.block_method (method)">block_method</a></span>, <span class='object_link'><a href="NodeWithBlock.html#exec_block-instance_method" title="Schemacop::NodeWithBlock#exec_block (method)">#exec_block</a></span></p>
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="Node.html" title="Schemacop::Node (class)">Node</a></span></h3>
|
210
|
+
<p class="inherited"><span class='object_link'><a href="Node.html#build-class_method" title="Schemacop::Node.build (method)">build</a></span>, <span class='object_link'><a href="Node.html#class_matches%3F-class_method" title="Schemacop::Node.class_matches? (method)">class_matches?</a></span>, <span class='object_link'><a href="Node.html#clear_klasses-class_method" title="Schemacop::Node.clear_klasses (method)">clear_klasses</a></span>, <span class='object_link'><a href="Node.html#clear_symbols-class_method" title="Schemacop::Node.clear_symbols (method)">clear_symbols</a></span>, <span class='object_link'><a href="Node.html#exec_block-instance_method" title="Schemacop::Node#exec_block (method)">#exec_block</a></span>, <span class='object_link'><a href="Node.html#klass-class_method" title="Schemacop::Node.klass (method)">klass</a></span>, <span class='object_link'><a href="Node.html#option-class_method" title="Schemacop::Node.option (method)">option</a></span>, <span class='object_link'><a href="Node.html#option-instance_method" title="Schemacop::Node#option (method)">#option</a></span>, <span class='object_link'><a href="Node.html#option%3F-instance_method" title="Schemacop::Node#option? (method)">#option?</a></span>, <span class='object_link'><a href="Node.html#register-class_method" title="Schemacop::Node.register (method)">register</a></span>, <span class='object_link'><a href="Node.html#resolve_type_klass-instance_method" title="Schemacop::Node#resolve_type_klass (method)">#resolve_type_klass</a></span>, <span class='object_link'><a href="Node.html#symbol-class_method" title="Schemacop::Node.symbol (method)">symbol</a></span>, <span class='object_link'><a href="Node.html#symbol_matches%3F-class_method" title="Schemacop::Node.symbol_matches? (method)">symbol_matches?</a></span>, <span class='object_link'><a href="Node.html#type_filter_matches%3F-instance_method" title="Schemacop::Node#type_filter_matches? (method)">#type_filter_matches?</a></span>, <span class='object_link'><a href="Node.html#type_label-instance_method" title="Schemacop::Node#type_label (method)">#type_label</a></span>, <span class='object_link'><a href="Node.html#type_matches%3F-class_method" title="Schemacop::Node.type_matches? (method)">type_matches?</a></span>, <span class='object_link'><a href="Node.html#type_matches%3F-instance_method" title="Schemacop::Node#type_matches? (method)">#type_matches?</a></span></p>
|
211
|
+
<div id="constructor_details" class="method_details_list">
|
212
|
+
<h2>Constructor Details</h2>
|
213
|
+
|
214
|
+
<div class="method_details first">
|
215
|
+
<h3 class="signature first" id="initialize-instance_method">
|
216
|
+
|
217
|
+
#<strong>initialize</strong>(*args) ⇒ <tt><span class='object_link'><a href="" title="Schemacop::ArrayValidator (class)">ArrayValidator</a></span></tt>
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
</h3><div class="docstring">
|
224
|
+
<div class="discussion">
|
225
|
+
<p>Returns a new instance of ArrayValidator</p>
|
226
|
+
|
227
|
+
|
228
|
+
</div>
|
229
|
+
</div>
|
230
|
+
<div class="tags">
|
231
|
+
|
232
|
+
|
233
|
+
</div><table class="source_code">
|
234
|
+
<tr>
|
235
|
+
<td>
|
236
|
+
<pre class="lines">
|
237
|
+
|
238
|
+
|
239
|
+
9
|
240
|
+
10
|
241
|
+
11
|
242
|
+
12</pre>
|
243
|
+
</td>
|
244
|
+
<td>
|
245
|
+
<pre class="code"><span class="info file"># File 'lib/schemacop/validator/array_validator.rb', line 9</span>
|
246
|
+
|
247
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
248
|
+
<span class='kw'>super</span>
|
249
|
+
<span class='id identifier rubyid_type'>type</span><span class='lparen'>(</span><span class='symbol'>:nil</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='symbol'>:nil</span><span class='rparen'>)</span>
|
250
|
+
<span class='kw'>end</span></pre>
|
251
|
+
</td>
|
252
|
+
</tr>
|
253
|
+
</table>
|
254
|
+
</div>
|
255
|
+
|
256
|
+
</div>
|
257
|
+
|
258
|
+
|
259
|
+
<div id="instance_method_details" class="method_details_list">
|
260
|
+
<h2>Instance Method Details</h2>
|
261
|
+
|
262
|
+
|
263
|
+
<div class="method_details first">
|
264
|
+
<h3 class="signature first" id="validate-instance_method">
|
265
|
+
|
266
|
+
#<strong>validate</strong>(data, collector) ⇒ <tt>Object</tt>
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
</h3><table class="source_code">
|
273
|
+
<tr>
|
274
|
+
<td>
|
275
|
+
<pre class="lines">
|
276
|
+
|
277
|
+
|
278
|
+
14
|
279
|
+
15
|
280
|
+
16
|
281
|
+
17
|
282
|
+
18
|
283
|
+
19
|
284
|
+
20
|
285
|
+
21
|
286
|
+
22
|
287
|
+
23
|
288
|
+
24
|
289
|
+
25
|
290
|
+
26
|
291
|
+
27
|
292
|
+
28</pre>
|
293
|
+
</td>
|
294
|
+
<td>
|
295
|
+
<pre class="code"><span class="info file"># File 'lib/schemacop/validator/array_validator.rb', line 14</span>
|
296
|
+
|
297
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_collector'>collector</span><span class='rparen'>)</span>
|
298
|
+
<span class='id identifier rubyid_validate_custom_check'>validate_custom_check</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_collector'>collector</span><span class='rparen'>)</span>
|
299
|
+
|
300
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_option?'>option?</span><span class='lparen'>(</span><span class='symbol'>:min</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'><</span> <span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='symbol'>:min</span><span class='rparen'>)</span>
|
301
|
+
<span class='id identifier rubyid_collector'>collector</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array must have more (>=) than </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='symbol'>:min</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'> elements.</span><span class='tstring_end'>"</span></span>
|
302
|
+
<span class='kw'>end</span>
|
303
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_option?'>option?</span><span class='lparen'>(</span><span class='symbol'>:max</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>></span> <span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='symbol'>:max</span><span class='rparen'>)</span>
|
304
|
+
<span class='id identifier rubyid_collector'>collector</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Array must have less (<=) than </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_option'>option</span><span class='lparen'>(</span><span class='symbol'>:max</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'> elements.</span><span class='tstring_end'>"</span></span>
|
305
|
+
<span class='kw'>end</span>
|
306
|
+
<span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_each_with_index'>each_with_index</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entry'>entry</span><span class='comma'>,</span> <span class='id identifier rubyid_index'>index</span><span class='op'>|</span>
|
307
|
+
<span class='id identifier rubyid_collector'>collector</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_index'>index</span><span class='embexpr_end'>}</span><span class='tstring_content'>]</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
|
308
|
+
<span class='id identifier rubyid_validate_types'>validate_types</span><span class='lparen'>(</span><span class='id identifier rubyid_entry'>entry</span><span class='comma'>,</span> <span class='id identifier rubyid_collector'>collector</span><span class='rparen'>)</span>
|
309
|
+
<span class='kw'>end</span>
|
310
|
+
<span class='kw'>end</span>
|
311
|
+
<span class='kw'>end</span></pre>
|
312
|
+
</td>
|
313
|
+
</tr>
|
314
|
+
</table>
|
315
|
+
</div>
|
316
|
+
|
317
|
+
</div>
|
318
|
+
|
319
|
+
</div>
|
320
|
+
|
321
|
+
<div id="footer">
|
322
|
+
Generated on Mon May 15 17:46:05 2017 by
|
323
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
324
|
+
0.9.9 (ruby-2.3.1).
|
325
|
+
</div>
|
326
|
+
|
327
|
+
</div>
|
328
|
+
</body>
|
329
|
+
</html>
|