schemacop 2.4.5 → 3.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +25 -1
  4. data/.travis.yml +3 -1
  5. data/CHANGELOG.md +32 -1
  6. data/README.md +53 -710
  7. data/README_V2.md +775 -0
  8. data/README_V3.md +1195 -0
  9. data/Rakefile +8 -12
  10. data/VERSION +1 -1
  11. data/lib/schemacop.rb +35 -36
  12. data/lib/schemacop/base_schema.rb +37 -0
  13. data/lib/schemacop/railtie.rb +10 -0
  14. data/lib/schemacop/schema.rb +1 -60
  15. data/lib/schemacop/schema2.rb +22 -0
  16. data/lib/schemacop/schema3.rb +21 -0
  17. data/lib/schemacop/scoped_env.rb +25 -13
  18. data/lib/schemacop/v2.rb +26 -0
  19. data/lib/schemacop/{caster.rb → v2/caster.rb} +16 -2
  20. data/lib/schemacop/{collector.rb → v2/collector.rb} +5 -2
  21. data/lib/schemacop/{dupper.rb → v2/dupper.rb} +1 -1
  22. data/lib/schemacop/{field_node.rb → v2/field_node.rb} +4 -3
  23. data/lib/schemacop/v2/node.rb +142 -0
  24. data/lib/schemacop/{node_resolver.rb → v2/node_resolver.rb} +1 -1
  25. data/lib/schemacop/v2/node_supporting_field.rb +70 -0
  26. data/lib/schemacop/{node_supporting_type.rb → v2/node_supporting_type.rb} +14 -11
  27. data/lib/schemacop/{node_with_block.rb → v2/node_with_block.rb} +3 -2
  28. data/lib/schemacop/v2/root_node.rb +6 -0
  29. data/lib/schemacop/v2/validator/array_validator.rb +32 -0
  30. data/lib/schemacop/{validator → v2/validator}/boolean_validator.rb +1 -1
  31. data/lib/schemacop/v2/validator/float_validator.rb +7 -0
  32. data/lib/schemacop/v2/validator/hash_validator.rb +37 -0
  33. data/lib/schemacop/v2/validator/integer_validator.rb +7 -0
  34. data/lib/schemacop/{validator → v2/validator}/nil_validator.rb +1 -1
  35. data/lib/schemacop/v2/validator/number_validator.rb +21 -0
  36. data/lib/schemacop/v2/validator/object_validator.rb +29 -0
  37. data/lib/schemacop/v2/validator/string_validator.rb +39 -0
  38. data/lib/schemacop/{validator → v2/validator}/symbol_validator.rb +1 -1
  39. data/lib/schemacop/v3.rb +45 -0
  40. data/lib/schemacop/v3/all_of_node.rb +27 -0
  41. data/lib/schemacop/v3/any_of_node.rb +28 -0
  42. data/lib/schemacop/v3/array_node.rb +218 -0
  43. data/lib/schemacop/v3/boolean_node.rb +16 -0
  44. data/lib/schemacop/v3/combination_node.rb +45 -0
  45. data/lib/schemacop/v3/context.rb +17 -0
  46. data/lib/schemacop/v3/dsl_scope.rb +46 -0
  47. data/lib/schemacop/v3/global_context.rb +114 -0
  48. data/lib/schemacop/v3/hash_node.rb +256 -0
  49. data/lib/schemacop/v3/integer_node.rb +13 -0
  50. data/lib/schemacop/v3/is_not_node.rb +32 -0
  51. data/lib/schemacop/v3/node.rb +215 -0
  52. data/lib/schemacop/v3/node_registry.rb +49 -0
  53. data/lib/schemacop/v3/number_node.rb +18 -0
  54. data/lib/schemacop/v3/numeric_node.rb +76 -0
  55. data/lib/schemacop/v3/object_node.rb +40 -0
  56. data/lib/schemacop/v3/one_of_node.rb +28 -0
  57. data/lib/schemacop/v3/reference_node.rb +49 -0
  58. data/lib/schemacop/v3/result.rb +58 -0
  59. data/lib/schemacop/v3/string_node.rb +124 -0
  60. data/lib/schemacop/v3/symbol_node.rb +13 -0
  61. data/schemacop.gemspec +24 -27
  62. data/test/lib/test_helper.rb +152 -0
  63. data/test/schemas/nested/group.rb +6 -0
  64. data/test/schemas/user.rb +7 -0
  65. data/test/unit/schemacop/v2/casting_test.rb +120 -0
  66. data/test/unit/schemacop/v2/collector_test.rb +47 -0
  67. data/test/unit/schemacop/v2/custom_check_test.rb +95 -0
  68. data/test/unit/schemacop/v2/custom_if_test.rb +97 -0
  69. data/test/unit/schemacop/v2/defaults_test.rb +95 -0
  70. data/test/unit/schemacop/v2/empty_test.rb +16 -0
  71. data/test/unit/schemacop/v2/nil_dis_allow_test.rb +43 -0
  72. data/test/unit/schemacop/v2/node_resolver_test.rb +28 -0
  73. data/test/unit/schemacop/v2/short_forms_test.rb +351 -0
  74. data/test/unit/schemacop/v2/types_test.rb +88 -0
  75. data/test/unit/schemacop/v2/validator_array_test.rb +99 -0
  76. data/test/unit/schemacop/v2/validator_boolean_test.rb +17 -0
  77. data/test/unit/schemacop/v2/validator_float_test.rb +59 -0
  78. data/test/unit/schemacop/v2/validator_hash_test.rb +95 -0
  79. data/test/unit/schemacop/v2/validator_integer_test.rb +48 -0
  80. data/test/unit/schemacop/v2/validator_nil_test.rb +15 -0
  81. data/test/unit/schemacop/v2/validator_number_test.rb +62 -0
  82. data/test/unit/schemacop/v2/validator_object_test.rb +141 -0
  83. data/test/unit/schemacop/v2/validator_string_test.rb +78 -0
  84. data/test/unit/schemacop/v2/validator_symbol_test.rb +18 -0
  85. data/test/unit/schemacop/v3/all_of_node_test.rb +198 -0
  86. data/test/unit/schemacop/v3/any_of_node_test.rb +218 -0
  87. data/test/unit/schemacop/v3/array_node_test.rb +815 -0
  88. data/test/unit/schemacop/v3/boolean_node_test.rb +126 -0
  89. data/test/unit/schemacop/v3/global_context_test.rb +164 -0
  90. data/test/unit/schemacop/v3/hash_node_test.rb +884 -0
  91. data/test/unit/schemacop/v3/integer_node_test.rb +323 -0
  92. data/test/unit/schemacop/v3/is_not_node_test.rb +173 -0
  93. data/test/unit/schemacop/v3/node_test.rb +148 -0
  94. data/test/unit/schemacop/v3/number_node_test.rb +292 -0
  95. data/test/unit/schemacop/v3/object_node_test.rb +170 -0
  96. data/test/unit/schemacop/v3/one_of_node_test.rb +187 -0
  97. data/test/unit/schemacop/v3/reference_node_test.rb +351 -0
  98. data/test/unit/schemacop/v3/string_node_test.rb +334 -0
  99. data/test/unit/schemacop/v3/symbol_node_test.rb +75 -0
  100. metadata +152 -145
  101. data/doc/Schemacop.html +0 -146
  102. data/doc/Schemacop/ArrayValidator.html +0 -329
  103. data/doc/Schemacop/BooleanValidator.html +0 -145
  104. data/doc/Schemacop/Caster.html +0 -379
  105. data/doc/Schemacop/Collector.html +0 -787
  106. data/doc/Schemacop/Dupper.html +0 -214
  107. data/doc/Schemacop/Exceptions.html +0 -115
  108. data/doc/Schemacop/Exceptions/InvalidSchemaError.html +0 -124
  109. data/doc/Schemacop/Exceptions/ValidationError.html +0 -124
  110. data/doc/Schemacop/FieldNode.html +0 -421
  111. data/doc/Schemacop/FloatValidator.html +0 -158
  112. data/doc/Schemacop/HashValidator.html +0 -293
  113. data/doc/Schemacop/IntegerValidator.html +0 -158
  114. data/doc/Schemacop/NilValidator.html +0 -145
  115. data/doc/Schemacop/Node.html +0 -1438
  116. data/doc/Schemacop/NodeResolver.html +0 -258
  117. data/doc/Schemacop/NodeSupportingField.html +0 -590
  118. data/doc/Schemacop/NodeSupportingType.html +0 -612
  119. data/doc/Schemacop/NodeWithBlock.html +0 -289
  120. data/doc/Schemacop/NumberValidator.html +0 -232
  121. data/doc/Schemacop/ObjectValidator.html +0 -298
  122. data/doc/Schemacop/RootNode.html +0 -171
  123. data/doc/Schemacop/Schema.html +0 -699
  124. data/doc/Schemacop/StringValidator.html +0 -295
  125. data/doc/Schemacop/SymbolValidator.html +0 -145
  126. data/doc/ScopedEnv.html +0 -351
  127. data/doc/_index.html +0 -379
  128. data/doc/class_list.html +0 -51
  129. data/doc/css/common.css +0 -1
  130. data/doc/css/full_list.css +0 -58
  131. data/doc/css/style.css +0 -496
  132. data/doc/file.README.html +0 -833
  133. data/doc/file_list.html +0 -56
  134. data/doc/frames.html +0 -17
  135. data/doc/index.html +0 -833
  136. data/doc/inheritance.graphml +0 -524
  137. data/doc/inheritance.pdf +0 -825
  138. data/doc/js/app.js +0 -303
  139. data/doc/js/full_list.js +0 -216
  140. data/doc/js/jquery.js +0 -4
  141. data/doc/method_list.html +0 -587
  142. data/doc/top-level-namespace.html +0 -112
  143. data/lib/schemacop/node.rb +0 -139
  144. data/lib/schemacop/node_supporting_field.rb +0 -58
  145. data/lib/schemacop/root_node.rb +0 -4
  146. data/lib/schemacop/validator/array_validator.rb +0 -30
  147. data/lib/schemacop/validator/float_validator.rb +0 -5
  148. data/lib/schemacop/validator/hash_validator.rb +0 -35
  149. data/lib/schemacop/validator/integer_validator.rb +0 -5
  150. data/lib/schemacop/validator/number_validator.rb +0 -19
  151. data/lib/schemacop/validator/object_validator.rb +0 -27
  152. data/lib/schemacop/validator/string_validator.rb +0 -37
  153. data/test/casting_test.rb +0 -90
  154. data/test/collector_test.rb +0 -45
  155. data/test/custom_check_test.rb +0 -93
  156. data/test/custom_if_test.rb +0 -95
  157. data/test/defaults_test.rb +0 -93
  158. data/test/empty_test.rb +0 -14
  159. data/test/nil_dis_allow_test.rb +0 -41
  160. data/test/node_resolver_test.rb +0 -26
  161. data/test/short_forms_test.rb +0 -349
  162. data/test/test_helper.rb +0 -13
  163. data/test/types_test.rb +0 -84
  164. data/test/validator_array_test.rb +0 -97
  165. data/test/validator_boolean_test.rb +0 -15
  166. data/test/validator_float_test.rb +0 -57
  167. data/test/validator_hash_test.rb +0 -93
  168. data/test/validator_integer_test.rb +0 -46
  169. data/test/validator_nil_test.rb +0 -13
  170. data/test/validator_number_test.rb +0 -60
  171. data/test/validator_object_test.rb +0 -139
  172. data/test/validator_string_test.rb +0 -76
  173. data/test/validator_symbol_test.rb +0 -16
@@ -1,699 +0,0 @@
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::Schema
8
-
9
- &mdash; Documentation by YARD 0.9.20
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::Schema";
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 (S)</a> &raquo;
40
- <span class='title'><span class='object_link'><a href="../Schemacop.html" title="Schemacop (module)">Schemacop</a></span></span>
41
- &raquo;
42
- <span class="title">Schema</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::Schema
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
- <dl>
70
- <dt>Inherits:</dt>
71
- <dd>
72
- <span class="inheritName">Object</span>
73
-
74
- <ul class="fullTree">
75
- <li>Object</li>
76
-
77
- <li class="next">Schemacop::Schema</li>
78
-
79
- </ul>
80
- <a href="#" class="inheritanceTree">show all</a>
81
-
82
- </dd>
83
- </dl>
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
- <dl>
96
- <dt>Defined in:</dt>
97
- <dd>lib/schemacop/schema.rb</dd>
98
- </dl>
99
-
100
- </div>
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
- <h2>
111
- Instance Method Summary
112
- <small><a href="#" class="summary_toggle">collapse</a></small>
113
- </h2>
114
-
115
- <ul class="summary">
116
-
117
- <li class="public ">
118
- <span class="summary_signature">
119
-
120
- <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(*args, &amp;block) &#x21d2; Schema </a>
121
-
122
-
123
-
124
- </span>
125
-
126
-
127
- <span class="note title constructor">constructor</span>
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
- <span class="summary_desc"><div class='inline'><p>Create a new Schema.</p>
137
- </div></span>
138
-
139
- </li>
140
-
141
-
142
- <li class="public ">
143
- <span class="summary_signature">
144
-
145
- <a href="#invalid%3F-instance_method" title="#invalid? (instance method)">#<strong>invalid?</strong>(data) &#x21d2; Boolean </a>
146
-
147
-
148
-
149
- </span>
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
- <span class="summary_desc"><div class='inline'><p>Query data validity.</p>
160
- </div></span>
161
-
162
- </li>
163
-
164
-
165
- <li class="public ">
166
- <span class="summary_signature">
167
-
168
- <a href="#valid%3F-instance_method" title="#valid? (instance method)">#<strong>valid?</strong>(data) &#x21d2; Boolean </a>
169
-
170
-
171
-
172
- </span>
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
- <span class="summary_desc"><div class='inline'><p>Query data validity.</p>
183
- </div></span>
184
-
185
- </li>
186
-
187
-
188
- <li class="public ">
189
- <span class="summary_signature">
190
-
191
- <a href="#validate-instance_method" title="#validate (instance method)">#<strong>validate</strong>(data) &#x21d2; Schemacop::Collector </a>
192
-
193
-
194
-
195
- </span>
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
- <span class="summary_desc"><div class='inline'><p>Validate data for the defined Schema.</p>
206
- </div></span>
207
-
208
- </li>
209
-
210
-
211
- <li class="public ">
212
- <span class="summary_signature">
213
-
214
- <a href="#validate!-instance_method" title="#validate! (instance method)">#<strong>validate!</strong>(data) &#x21d2; Object </a>
215
-
216
-
217
-
218
- </span>
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
- <span class="summary_desc"><div class='inline'><p>Validate data for the defined Schema.</p>
229
- </div></span>
230
-
231
- </li>
232
-
233
-
234
- </ul>
235
-
236
-
237
- <div id="constructor_details" class="method_details_list">
238
- <h2>Constructor Details</h2>
239
-
240
- <div class="method_details first">
241
- <h3 class="signature first" id="initialize-instance_method">
242
-
243
- #<strong>initialize</strong>(*args, &amp;block) &#x21d2; <tt><span class='object_link'><a href="" title="Schemacop::Schema (class)">Schema</a></span></tt>
244
-
245
-
246
-
247
-
248
-
249
- </h3><div class="docstring">
250
- <div class="discussion">
251
- <p>Create a new Schema</p>
252
-
253
- <p>For detailed usage, please refer to README.md in the root of this project.</p>
254
-
255
-
256
- </div>
257
- </div>
258
- <div class="tags">
259
- <p class="tag_title">Parameters:</p>
260
- <ul class="param">
261
-
262
- <li>
263
-
264
- <span class='name'>args</span>
265
-
266
-
267
- <span class='type'>(<tt>Array</tt>)</span>
268
-
269
-
270
-
271
- &mdash;
272
- <div class='inline'><p>An array of arguments to apply to the root node of the
273
- Schema.</p>
274
- </div>
275
-
276
- </li>
277
-
278
- <li>
279
-
280
- <span class='name'>block</span>
281
-
282
-
283
- <span class='type'></span>
284
-
285
-
286
-
287
- &mdash;
288
- <div class='inline'><p>A block with further Schema specification.</p>
289
- </div>
290
-
291
- </li>
292
-
293
- </ul>
294
-
295
- <p class="tag_title">Raises:</p>
296
- <ul class="raise">
297
-
298
- <li>
299
-
300
-
301
- <span class='type'>(<tt><span class='object_link'><a href="Exceptions/InvalidSchemaError.html" title="Schemacop::Exceptions::InvalidSchemaError (class)">Schemacop::Exceptions::InvalidSchemaError</a></span></tt>)</span>
302
-
303
-
304
-
305
- &mdash;
306
- <div class='inline'><p>If the Schema defined
307
- is invalid.</p>
308
- </div>
309
-
310
- </li>
311
-
312
- </ul>
313
-
314
- </div><table class="source_code">
315
- <tr>
316
- <td>
317
- <pre class="lines">
318
-
319
-
320
- 12
321
- 13
322
- 14
323
- 15
324
- 16</pre>
325
- </td>
326
- <td>
327
- <pre class="code"><span class="info file"># File 'lib/schemacop/schema.rb', line 12</span>
328
-
329
- <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='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
330
- <span class='ivar'>@root</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="HashValidator.html" title="Schemacop::HashValidator (class)">HashValidator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="NodeSupportingField.html#initialize-instance_method" title="Schemacop::NodeSupportingField#initialize (method)">new</a></span></span> <span class='kw'>do</span>
331
- <span class='id identifier rubyid_req'>req</span> <span class='symbol'>:root</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span>
332
- <span class='kw'>end</span>
333
- <span class='kw'>end</span></pre>
334
- </td>
335
- </tr>
336
- </table>
337
- </div>
338
-
339
- </div>
340
-
341
-
342
- <div id="instance_method_details" class="method_details_list">
343
- <h2>Instance Method Details</h2>
344
-
345
-
346
- <div class="method_details first">
347
- <h3 class="signature first" id="invalid?-instance_method">
348
-
349
- #<strong>invalid?</strong>(data) &#x21d2; <tt>Boolean</tt>
350
-
351
-
352
-
353
-
354
-
355
- </h3><div class="docstring">
356
- <div class="discussion">
357
- <p>Query data validity</p>
358
-
359
-
360
- </div>
361
- </div>
362
- <div class="tags">
363
- <p class="tag_title">Parameters:</p>
364
- <ul class="param">
365
-
366
- <li>
367
-
368
- <span class='name'>data</span>
369
-
370
-
371
- <span class='type'></span>
372
-
373
-
374
-
375
- &mdash;
376
- <div class='inline'><p>The data to validate.</p>
377
- </div>
378
-
379
- </li>
380
-
381
- </ul>
382
-
383
- <p class="tag_title">Returns:</p>
384
- <ul class="return">
385
-
386
- <li>
387
-
388
-
389
- <span class='type'>(<tt>Boolean</tt>)</span>
390
-
391
-
392
-
393
- &mdash;
394
- <div class='inline'><p>True if data is invalid, false otherwise.</p>
395
- </div>
396
-
397
- </li>
398
-
399
- </ul>
400
-
401
- </div><table class="source_code">
402
- <tr>
403
- <td>
404
- <pre class="lines">
405
-
406
-
407
- 30
408
- 31
409
- 32</pre>
410
- </td>
411
- <td>
412
- <pre class="code"><span class="info file"># File 'lib/schemacop/schema.rb', line 30</span>
413
-
414
- <span class='kw'>def</span> <span class='id identifier rubyid_invalid?'>invalid?</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
415
- <span class='op'>!</span><span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
416
- <span class='kw'>end</span></pre>
417
- </td>
418
- </tr>
419
- </table>
420
- </div>
421
-
422
- <div class="method_details ">
423
- <h3 class="signature " id="valid?-instance_method">
424
-
425
- #<strong>valid?</strong>(data) &#x21d2; <tt>Boolean</tt>
426
-
427
-
428
-
429
-
430
-
431
- </h3><div class="docstring">
432
- <div class="discussion">
433
- <p>Query data validity</p>
434
-
435
-
436
- </div>
437
- </div>
438
- <div class="tags">
439
- <p class="tag_title">Parameters:</p>
440
- <ul class="param">
441
-
442
- <li>
443
-
444
- <span class='name'>data</span>
445
-
446
-
447
- <span class='type'></span>
448
-
449
-
450
-
451
- &mdash;
452
- <div class='inline'><p>The data to validate.</p>
453
- </div>
454
-
455
- </li>
456
-
457
- </ul>
458
-
459
- <p class="tag_title">Returns:</p>
460
- <ul class="return">
461
-
462
- <li>
463
-
464
-
465
- <span class='type'>(<tt>Boolean</tt>)</span>
466
-
467
-
468
-
469
- &mdash;
470
- <div class='inline'><p>True if the data is valid, false otherwise.</p>
471
- </div>
472
-
473
- </li>
474
-
475
- </ul>
476
-
477
- </div><table class="source_code">
478
- <tr>
479
- <td>
480
- <pre class="lines">
481
-
482
-
483
- 22
484
- 23
485
- 24</pre>
486
- </td>
487
- <td>
488
- <pre class="code"><span class="info file"># File 'lib/schemacop/schema.rb', line 22</span>
489
-
490
- <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
491
- <span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_valid?'>valid?</span>
492
- <span class='kw'>end</span></pre>
493
- </td>
494
- </tr>
495
- </table>
496
- </div>
497
-
498
- <div class="method_details ">
499
- <h3 class="signature " id="validate-instance_method">
500
-
501
- #<strong>validate</strong>(data) &#x21d2; <tt><span class='object_link'><a href="Collector.html" title="Schemacop::Collector (class)">Schemacop::Collector</a></span></tt>
502
-
503
-
504
-
505
-
506
-
507
- </h3><div class="docstring">
508
- <div class="discussion">
509
- <p>Validate data for the defined Schema</p>
510
-
511
-
512
- </div>
513
- </div>
514
- <div class="tags">
515
- <p class="tag_title">Parameters:</p>
516
- <ul class="param">
517
-
518
- <li>
519
-
520
- <span class='name'>data</span>
521
-
522
-
523
- <span class='type'></span>
524
-
525
-
526
-
527
- &mdash;
528
- <div class='inline'><p>The data to validate.</p>
529
- </div>
530
-
531
- </li>
532
-
533
- </ul>
534
-
535
- <p class="tag_title">Returns:</p>
536
- <ul class="return">
537
-
538
- <li>
539
-
540
-
541
- <span class='type'>(<tt><span class='object_link'><a href="Collector.html" title="Schemacop::Collector (class)">Schemacop::Collector</a></span></tt>)</span>
542
-
543
-
544
-
545
- &mdash;
546
- <div class='inline'><p>The object that collected errors
547
- throughout the validation.</p>
548
- </div>
549
-
550
- </li>
551
-
552
- </ul>
553
-
554
- </div><table class="source_code">
555
- <tr>
556
- <td>
557
- <pre class="lines">
558
-
559
-
560
- 39
561
- 40
562
- 41
563
- 42
564
- 43
565
- 44</pre>
566
- </td>
567
- <td>
568
- <pre class="code"><span class="info file"># File 'lib/schemacop/schema.rb', line 39</span>
569
-
570
- <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='rparen'>)</span>
571
- <span class='id identifier rubyid_dupped_data'>dupped_data</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Schemacop.html" title="Schemacop (module)">Schemacop</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Dupper.html" title="Schemacop::Dupper (class)">Dupper</a></span></span><span class='period'>.</span><span class='id identifier rubyid_dup_data'><span class='object_link'><a href="Dupper.html#dup_data-class_method" title="Schemacop::Dupper.dup_data (method)">dup_data</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
572
- <span class='id identifier rubyid_collector'>collector</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Collector.html" title="Schemacop::Collector (class)">Collector</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Collector.html#initialize-instance_method" title="Schemacop::Collector#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_dupped_data'>dupped_data</span><span class='rparen'>)</span>
573
- <span class='ivar'>@root</span><span class='period'>.</span><span class='id identifier rubyid_fields'>fields</span><span class='lbracket'>[</span><span class='symbol'>:root</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='lbrace'>{</span> <span class='label'>root:</span> <span class='id identifier rubyid_data'>data</span> <span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_collector'>collector</span><span class='period'>.</span><span class='id identifier rubyid_ignore_next_segment'>ignore_next_segment</span><span class='rparen'>)</span>
574
- <span class='kw'>return</span> <span class='id identifier rubyid_collector'>collector</span>
575
- <span class='kw'>end</span></pre>
576
- </td>
577
- </tr>
578
- </table>
579
- </div>
580
-
581
- <div class="method_details ">
582
- <h3 class="signature " id="validate!-instance_method">
583
-
584
- #<strong>validate!</strong>(data) &#x21d2; <tt>Object</tt>
585
-
586
-
587
-
588
-
589
-
590
- </h3><div class="docstring">
591
- <div class="discussion">
592
- <p>Validate data for the defined Schema</p>
593
-
594
-
595
- </div>
596
- </div>
597
- <div class="tags">
598
- <p class="tag_title">Parameters:</p>
599
- <ul class="param">
600
-
601
- <li>
602
-
603
- <span class='name'>data</span>
604
-
605
-
606
- <span class='type'></span>
607
-
608
-
609
-
610
- &mdash;
611
- <div class='inline'><p>The data to validate.</p>
612
- </div>
613
-
614
- </li>
615
-
616
- </ul>
617
-
618
- <p class="tag_title">Returns:</p>
619
- <ul class="return">
620
-
621
- <li>
622
-
623
-
624
- <span class='type'></span>
625
-
626
-
627
-
628
-
629
- <div class='inline'><p>nil</p>
630
- </div>
631
-
632
- </li>
633
-
634
- </ul>
635
- <p class="tag_title">Raises:</p>
636
- <ul class="raise">
637
-
638
- <li>
639
-
640
-
641
- <span class='type'>(<tt><span class='object_link'><a href="Exceptions/ValidationError.html" title="Schemacop::Exceptions::ValidationError (class)">Schemacop::Exceptions::ValidationError</a></span></tt>)</span>
642
-
643
-
644
-
645
- &mdash;
646
- <div class='inline'><p>If the data is invalid,
647
- this exception is thrown.</p>
648
- </div>
649
-
650
- </li>
651
-
652
- </ul>
653
-
654
- </div><table class="source_code">
655
- <tr>
656
- <td>
657
- <pre class="lines">
658
-
659
-
660
- 52
661
- 53
662
- 54
663
- 55
664
- 56
665
- 57
666
- 58
667
- 59
668
- 60</pre>
669
- </td>
670
- <td>
671
- <pre class="code"><span class="info file"># File 'lib/schemacop/schema.rb', line 52</span>
672
-
673
- <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='rparen'>)</span>
674
- <span class='id identifier rubyid_collector'>collector</span> <span class='op'>=</span> <span class='id identifier rubyid_validate'>validate</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
675
-
676
- <span class='kw'>unless</span> <span class='id identifier rubyid_collector'>collector</span><span class='period'>.</span><span class='id identifier rubyid_valid?'>valid?</span>
677
- <span class='id identifier rubyid_fail'>fail</span> <span class='const'><span class='object_link'><a href="Exceptions.html" title="Schemacop::Exceptions (module)">Exceptions</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Exceptions/ValidationError.html" title="Schemacop::Exceptions::ValidationError (class)">ValidationError</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_collector'>collector</span><span class='period'>.</span><span class='id identifier rubyid_exception_message'>exception_message</span>
678
- <span class='kw'>end</span>
679
-
680
- <span class='kw'>return</span> <span class='id identifier rubyid_collector'>collector</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span>
681
- <span class='kw'>end</span></pre>
682
- </td>
683
- </tr>
684
- </table>
685
- </div>
686
-
687
- </div>
688
-
689
- </div>
690
-
691
- <div id="footer">
692
- Generated on Wed May 13 10:52:04 2020 by
693
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
694
- 0.9.20 (ruby-2.6.2).
695
- </div>
696
-
697
- </div>
698
- </body>
699
- </html>