schemacop 2.0.0 → 2.3.2
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 +5 -5
- data/.rubocop.yml +1 -17
- data/.travis.yml +0 -2
- data/CHANGELOG.md +49 -0
- data/LICENSE +1 -1
- data/README.md +66 -17
- data/Rakefile +5 -1
- data/VERSION +1 -1
- data/doc/Schemacop.html +5 -5
- data/doc/Schemacop/ArrayValidator.html +3 -3
- data/doc/Schemacop/BooleanValidator.html +4 -4
- data/doc/Schemacop/Collector.html +208 -32
- data/doc/Schemacop/Exceptions.html +3 -3
- data/doc/Schemacop/Exceptions/InvalidSchemaError.html +3 -3
- data/doc/Schemacop/Exceptions/ValidationError.html +3 -3
- data/doc/Schemacop/FieldNode.html +3 -3
- data/doc/Schemacop/FloatValidator.html +4 -4
- data/doc/Schemacop/HashValidator.html +33 -7
- data/doc/Schemacop/IntegerValidator.html +4 -4
- data/doc/Schemacop/NilValidator.html +4 -4
- data/doc/Schemacop/Node.html +4 -4
- data/doc/Schemacop/NodeResolver.html +3 -3
- data/doc/Schemacop/NodeSupportingField.html +4 -4
- data/doc/Schemacop/NodeSupportingType.html +4 -4
- data/doc/Schemacop/NodeWithBlock.html +4 -4
- data/doc/Schemacop/NumberValidator.html +4 -4
- data/doc/Schemacop/ObjectValidator.html +20 -10
- data/doc/Schemacop/RootNode.html +4 -4
- data/doc/Schemacop/Schema.html +4 -4
- data/doc/Schemacop/StringValidator.html +3 -3
- data/doc/Schemacop/SymbolValidator.html +145 -0
- data/doc/ScopedEnv.html +3 -3
- data/doc/_index.html +11 -4
- data/doc/class_list.html +1 -1
- data/doc/css/style.css +10 -6
- data/doc/file.README.html +76 -30
- data/doc/frames.html +1 -1
- data/doc/index.html +76 -30
- data/doc/js/app.js +55 -0
- data/doc/method_list.html +57 -41
- data/doc/top-level-namespace.html +3 -3
- data/lib/schemacop.rb +2 -0
- data/lib/schemacop/collector.rb +21 -2
- data/lib/schemacop/node.rb +6 -2
- data/lib/schemacop/node_supporting_field.rb +2 -6
- data/lib/schemacop/schema.rb +1 -1
- data/lib/schemacop/validator/hash_validator.rb +15 -2
- data/lib/schemacop/validator/object_validator.rb +7 -1
- data/lib/schemacop/validator/symbol_validator.rb +5 -0
- data/schemacop.gemspec +9 -9
- data/test/collector_test.rb +45 -0
- data/test/custom_check_test.rb +7 -0
- data/test/short_forms_test.rb +15 -0
- data/test/types_test.rb +1 -0
- data/test/validator_object_test.rb +18 -0
- data/test/validator_symbol_test.rb +16 -0
- metadata +23 -18
data/doc/Schemacop/RootNode.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Schemacop::RootNode
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.20
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -149,7 +149,7 @@
|
|
149
149
|
|
150
150
|
|
151
151
|
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="Node.html" title="Schemacop::Node (class)">Node</a></span></h3>
|
152
|
-
<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#initialize-instance_method" title="Schemacop::Node#initialize (method)">#initialize</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-
|
152
|
+
<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#initialize-instance_method" title="Schemacop::Node#initialize (method)">#initialize</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-instance_method" title="Schemacop::Node#type_matches? (method)">#type_matches?</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#validate-instance_method" title="Schemacop::Node#validate (method)">#validate</a></span></p>
|
153
153
|
<div id="constructor_details" class="method_details_list">
|
154
154
|
<h2>Constructor Details</h2>
|
155
155
|
|
@@ -161,9 +161,9 @@
|
|
161
161
|
</div>
|
162
162
|
|
163
163
|
<div id="footer">
|
164
|
-
Generated on
|
164
|
+
Generated on Thu Sep 26 13:19:46 2019 by
|
165
165
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
166
|
-
0.9.
|
166
|
+
0.9.20 (ruby-2.6.2).
|
167
167
|
</div>
|
168
168
|
|
169
169
|
</div>
|
data/doc/Schemacop/Schema.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Schemacop::Schema
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.20
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -568,7 +568,7 @@ throughout the validation.</p>
|
|
568
568
|
|
569
569
|
<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>
|
570
570
|
<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>
|
571
|
-
<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='rparen'>)</span>
|
571
|
+
<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>
|
572
572
|
<span class='kw'>return</span> <span class='id identifier rubyid_collector'>collector</span>
|
573
573
|
<span class='kw'>end</span></pre>
|
574
574
|
</td>
|
@@ -687,9 +687,9 @@ this exception is thrown.</p>
|
|
687
687
|
</div>
|
688
688
|
|
689
689
|
<div id="footer">
|
690
|
-
Generated on
|
690
|
+
Generated on Thu Sep 26 13:19:46 2019 by
|
691
691
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
692
|
-
0.9.
|
692
|
+
0.9.20 (ruby-2.6.2).
|
693
693
|
</div>
|
694
694
|
|
695
695
|
</div>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Schemacop::StringValidator
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.20
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -285,9 +285,9 @@
|
|
285
285
|
</div>
|
286
286
|
|
287
287
|
<div id="footer">
|
288
|
-
Generated on
|
288
|
+
Generated on Thu Sep 26 13:19:47 2019 by
|
289
289
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
290
|
-
0.9.
|
290
|
+
0.9.20 (ruby-2.6.2).
|
291
291
|
</div>
|
292
292
|
|
293
293
|
</div>
|
@@ -0,0 +1,145 @@
|
|
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::SymbolValidator
|
8
|
+
|
9
|
+
— 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::SymbolValidator";
|
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> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Schemacop.html" title="Schemacop (module)">Schemacop</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">SymbolValidator</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::SymbolValidator
|
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="Node.html" title="Schemacop::Node (class)">Node</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">Schemacop::SymbolValidator</li>
|
80
|
+
|
81
|
+
</ul>
|
82
|
+
<a href="#" class="inheritanceTree">show all</a>
|
83
|
+
|
84
|
+
</dd>
|
85
|
+
</dl>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<dl>
|
98
|
+
<dt>Defined in:</dt>
|
99
|
+
<dd>lib/schemacop/validator/symbol_validator.rb</dd>
|
100
|
+
</dl>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
<h2>Instance Attribute Summary</h2>
|
111
|
+
|
112
|
+
<h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Node.html" title="Schemacop::Node (class)">Node</a></span></h3>
|
113
|
+
<p class="inherited"><span class='object_link'><a href="Node.html#options-instance_method" title="Schemacop::Node#options (method)">#options</a></span></p>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
<h2>Method Summary</h2>
|
124
|
+
|
125
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="Node.html" title="Schemacop::Node (class)">Node</a></span></h3>
|
126
|
+
<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#initialize-instance_method" title="Schemacop::Node#initialize (method)">#initialize</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-instance_method" title="Schemacop::Node#type_matches? (method)">#type_matches?</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#validate-instance_method" title="Schemacop::Node#validate (method)">#validate</a></span></p>
|
127
|
+
<div id="constructor_details" class="method_details_list">
|
128
|
+
<h2>Constructor Details</h2>
|
129
|
+
|
130
|
+
<p class="notice">This class inherits a constructor from <span class='object_link'><a href="Node.html#initialize-instance_method" title="Schemacop::Node#initialize (method)">Schemacop::Node</a></span></p>
|
131
|
+
|
132
|
+
</div>
|
133
|
+
|
134
|
+
|
135
|
+
</div>
|
136
|
+
|
137
|
+
<div id="footer">
|
138
|
+
Generated on Thu Sep 26 13:19:47 2019 by
|
139
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
140
|
+
0.9.20 (ruby-2.6.2).
|
141
|
+
</div>
|
142
|
+
|
143
|
+
</div>
|
144
|
+
</body>
|
145
|
+
</html>
|
data/doc/ScopedEnv.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: ScopedEnv
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.20
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -341,9 +341,9 @@
|
|
341
341
|
</div>
|
342
342
|
|
343
343
|
<div id="footer">
|
344
|
-
Generated on
|
344
|
+
Generated on Thu Sep 26 13:19:46 2019 by
|
345
345
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
346
|
-
0.9.
|
346
|
+
0.9.20 (ruby-2.6.2).
|
347
347
|
</div>
|
348
348
|
|
349
349
|
</div>
|
data/doc/_index.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<meta charset="utf-8">
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
6
|
<title>
|
7
|
-
Documentation by YARD 0.9.
|
7
|
+
Documentation by YARD 0.9.20
|
8
8
|
|
9
9
|
</title>
|
10
10
|
|
@@ -52,7 +52,7 @@
|
|
52
52
|
<div class="clear"></div>
|
53
53
|
</div>
|
54
54
|
|
55
|
-
<div id="content"><h1 class="noborder title">Documentation by YARD 0.9.
|
55
|
+
<div id="content"><h1 class="noborder title">Documentation by YARD 0.9.20</h1>
|
56
56
|
<div id="listing">
|
57
57
|
<h1 class="alphaindex">Alphabetic Index</h1>
|
58
58
|
|
@@ -313,6 +313,13 @@
|
|
313
313
|
|
314
314
|
</li>
|
315
315
|
|
316
|
+
<li>
|
317
|
+
<span class='object_link'><a href="Schemacop/SymbolValidator.html" title="Schemacop::SymbolValidator (class)">SymbolValidator</a></span>
|
318
|
+
|
319
|
+
<small>(Schemacop)</small>
|
320
|
+
|
321
|
+
</li>
|
322
|
+
|
316
323
|
</ul>
|
317
324
|
</ul>
|
318
325
|
|
@@ -340,9 +347,9 @@
|
|
340
347
|
</div>
|
341
348
|
|
342
349
|
<div id="footer">
|
343
|
-
Generated on
|
350
|
+
Generated on Thu Sep 26 13:19:46 2019 by
|
344
351
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
345
|
-
0.9.
|
352
|
+
0.9.20 (ruby-2.6.2).
|
346
353
|
</div>
|
347
354
|
|
348
355
|
</div>
|
data/doc/class_list.html
CHANGED
@@ -43,7 +43,7 @@
|
|
43
43
|
|
44
44
|
<ul id="full_list" class="class">
|
45
45
|
<li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li>
|
46
|
-
<li id='object_Schemacop' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="Schemacop.html" title="Schemacop (module)">Schemacop</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Schemacop::ArrayValidator' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/ArrayValidator.html" title="Schemacop::ArrayValidator (class)">ArrayValidator</a></span> < NodeSupportingType<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::BooleanValidator' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/BooleanValidator.html" title="Schemacop::BooleanValidator (class)">BooleanValidator</a></span> < Node<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::Collector' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/Collector.html" title="Schemacop::Collector (class)">Collector</a></span> < Object<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::Exceptions' class='collapsed even'><div class='item' style='padding-left:45px'><a class='toggle'></a> <span class='object_link'><a href="Schemacop/Exceptions.html" title="Schemacop::Exceptions (module)">Exceptions</a></span><small class='search_info'>Schemacop</small></div><ul><li id='object_Schemacop::Exceptions::InvalidSchemaError' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Schemacop/Exceptions/InvalidSchemaError.html" title="Schemacop::Exceptions::InvalidSchemaError (class)">InvalidSchemaError</a></span> < RuntimeError<small class='search_info'>Schemacop::Exceptions</small></div></li><li id='object_Schemacop::Exceptions::ValidationError' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Schemacop/Exceptions/ValidationError.html" title="Schemacop::Exceptions::ValidationError (class)">ValidationError</a></span> < RuntimeError<small class='search_info'>Schemacop::Exceptions</small></div></li></ul></li><li id='object_Schemacop::FieldNode' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/FieldNode.html" title="Schemacop::FieldNode (class)">FieldNode</a></span> < NodeSupportingType<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::FloatValidator' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/FloatValidator.html" title="Schemacop::FloatValidator (class)">FloatValidator</a></span> < NumberValidator<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::HashValidator' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/HashValidator.html" title="Schemacop::HashValidator (class)">HashValidator</a></span> < NodeSupportingField<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::IntegerValidator' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/IntegerValidator.html" title="Schemacop::IntegerValidator (class)">IntegerValidator</a></span> < NumberValidator<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::NilValidator' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/NilValidator.html" title="Schemacop::NilValidator (class)">NilValidator</a></span> < Node<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::Node' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/Node.html" title="Schemacop::Node (class)">Node</a></span> < Object<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::NodeResolver' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/NodeResolver.html" title="Schemacop::NodeResolver (class)">NodeResolver</a></span> < Object<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::NodeSupportingField' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/NodeSupportingField.html" title="Schemacop::NodeSupportingField (class)">NodeSupportingField</a></span> < NodeWithBlock<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::NodeSupportingType' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/NodeSupportingType.html" title="Schemacop::NodeSupportingType (class)">NodeSupportingType</a></span> < NodeWithBlock<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::NodeWithBlock' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/NodeWithBlock.html" title="Schemacop::NodeWithBlock (class)">NodeWithBlock</a></span> < Node<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::NumberValidator' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/NumberValidator.html" title="Schemacop::NumberValidator (class)">NumberValidator</a></span> < Node<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::ObjectValidator' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/ObjectValidator.html" title="Schemacop::ObjectValidator (class)">ObjectValidator</a></span> < Node<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::RootNode' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/RootNode.html" title="Schemacop::RootNode (class)">RootNode</a></span> < NodeSupportingType<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::Schema' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/Schema.html" title="Schemacop::Schema (class)">Schema</a></span> < Object<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::StringValidator' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/StringValidator.html" title="Schemacop::StringValidator (class)">StringValidator</a></span> < Node<small class='search_info'>Schemacop</small></div></li></ul></li><li id='object_ScopedEnv' class='
|
46
|
+
<li id='object_Schemacop' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="Schemacop.html" title="Schemacop (module)">Schemacop</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Schemacop::ArrayValidator' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/ArrayValidator.html" title="Schemacop::ArrayValidator (class)">ArrayValidator</a></span> < NodeSupportingType<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::BooleanValidator' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/BooleanValidator.html" title="Schemacop::BooleanValidator (class)">BooleanValidator</a></span> < Node<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::Collector' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/Collector.html" title="Schemacop::Collector (class)">Collector</a></span> < Object<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::Exceptions' class='collapsed even'><div class='item' style='padding-left:45px'><a class='toggle'></a> <span class='object_link'><a href="Schemacop/Exceptions.html" title="Schemacop::Exceptions (module)">Exceptions</a></span><small class='search_info'>Schemacop</small></div><ul><li id='object_Schemacop::Exceptions::InvalidSchemaError' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Schemacop/Exceptions/InvalidSchemaError.html" title="Schemacop::Exceptions::InvalidSchemaError (class)">InvalidSchemaError</a></span> < RuntimeError<small class='search_info'>Schemacop::Exceptions</small></div></li><li id='object_Schemacop::Exceptions::ValidationError' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Schemacop/Exceptions/ValidationError.html" title="Schemacop::Exceptions::ValidationError (class)">ValidationError</a></span> < RuntimeError<small class='search_info'>Schemacop::Exceptions</small></div></li></ul></li><li id='object_Schemacop::FieldNode' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/FieldNode.html" title="Schemacop::FieldNode (class)">FieldNode</a></span> < NodeSupportingType<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::FloatValidator' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/FloatValidator.html" title="Schemacop::FloatValidator (class)">FloatValidator</a></span> < NumberValidator<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::HashValidator' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/HashValidator.html" title="Schemacop::HashValidator (class)">HashValidator</a></span> < NodeSupportingField<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::IntegerValidator' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/IntegerValidator.html" title="Schemacop::IntegerValidator (class)">IntegerValidator</a></span> < NumberValidator<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::NilValidator' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/NilValidator.html" title="Schemacop::NilValidator (class)">NilValidator</a></span> < Node<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::Node' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/Node.html" title="Schemacop::Node (class)">Node</a></span> < Object<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::NodeResolver' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/NodeResolver.html" title="Schemacop::NodeResolver (class)">NodeResolver</a></span> < Object<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::NodeSupportingField' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/NodeSupportingField.html" title="Schemacop::NodeSupportingField (class)">NodeSupportingField</a></span> < NodeWithBlock<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::NodeSupportingType' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/NodeSupportingType.html" title="Schemacop::NodeSupportingType (class)">NodeSupportingType</a></span> < NodeWithBlock<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::NodeWithBlock' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/NodeWithBlock.html" title="Schemacop::NodeWithBlock (class)">NodeWithBlock</a></span> < Node<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::NumberValidator' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/NumberValidator.html" title="Schemacop::NumberValidator (class)">NumberValidator</a></span> < Node<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::ObjectValidator' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/ObjectValidator.html" title="Schemacop::ObjectValidator (class)">ObjectValidator</a></span> < Node<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::RootNode' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/RootNode.html" title="Schemacop::RootNode (class)">RootNode</a></span> < NodeSupportingType<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::Schema' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/Schema.html" title="Schemacop::Schema (class)">Schema</a></span> < Object<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::StringValidator' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/StringValidator.html" title="Schemacop::StringValidator (class)">StringValidator</a></span> < Node<small class='search_info'>Schemacop</small></div></li><li id='object_Schemacop::SymbolValidator' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Schemacop/SymbolValidator.html" title="Schemacop::SymbolValidator (class)">SymbolValidator</a></span> < Node<small class='search_info'>Schemacop</small></div></li></ul></li><li id='object_ScopedEnv' class='odd'><div class='item' style='padding-left:30px'><span class='object_link'><a href="ScopedEnv.html" title="ScopedEnv (class)">ScopedEnv</a></span> < Object<small class='search_info'>Top Level Namespace</small></div></li>
|
47
47
|
|
48
48
|
</ul>
|
49
49
|
</div>
|
data/doc/css/style.css
CHANGED
@@ -245,6 +245,7 @@ ul.toplevel { list-style: none; padding-left: 0; font-size: 1.1em; }
|
|
245
245
|
|
246
246
|
dl.constants { margin-left: 10px; }
|
247
247
|
dl.constants dt { font-weight: bold; font-size: 1.1em; margin-bottom: 5px; }
|
248
|
+
dl.constants.compact dt { display: inline-block; font-weight: normal }
|
248
249
|
dl.constants dd { width: 75%; white-space: pre; font-family: monospace; margin-bottom: 18px; }
|
249
250
|
dl.constants .docstring .note:first-child { margin-top: 5px; }
|
250
251
|
|
@@ -326,13 +327,9 @@ ul.summary a, ul.summary a:visited {
|
|
326
327
|
text-decoration: none; font-size: 1.1em;
|
327
328
|
}
|
328
329
|
ul.summary li { margin-bottom: 5px; }
|
329
|
-
.
|
330
|
-
padding: 4px 8px;
|
331
|
-
background: #f8f8f8;
|
332
|
-
border: 1px solid #f0f0f0;
|
333
|
-
border-radius: 5px;
|
334
|
-
}
|
330
|
+
.summary_signature { padding: 4px 8px; background: #f8f8f8; border: 1px solid #f0f0f0; border-radius: 5px; }
|
335
331
|
.summary_signature:hover { background: #CFEBFF; border-color: #A4CCDA; cursor: pointer; }
|
332
|
+
.summary_signature.deprecated { background: #ffe5e5; border-color: #e9dada; }
|
336
333
|
ul.summary.compact li { display: inline-block; margin: 0px 5px 0px 0px; line-height: 2.6em;}
|
337
334
|
ul.summary.compact .summary_signature { padding: 5px 7px; padding-right: 4px; }
|
338
335
|
#content .summary_signature:hover a,
|
@@ -484,6 +481,13 @@ pre.code .rubyid_backref,
|
|
484
481
|
pre.code .rubyid_nth_ref { color: #6D79DE; }
|
485
482
|
pre.code .regexp, .dregexp { color: #036A07; }
|
486
483
|
pre.code a { border-bottom: 1px dotted #bbf; }
|
484
|
+
/* inline code */
|
485
|
+
*:not(pre) > code {
|
486
|
+
padding: 1px 3px 1px 3px;
|
487
|
+
border: 1px solid #E1E1E8;
|
488
|
+
background: #F7F7F9;
|
489
|
+
border-radius: 4px;
|
490
|
+
}
|
487
491
|
|
488
492
|
/* Color fix for links */
|
489
493
|
#content .summary_desc pre.code .id > .object_link a, /* identifier */
|
data/doc/file.README.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
File: README
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.20
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -132,7 +132,7 @@ around at runtime. Those two steps look as follows:</p>
|
|
132
132
|
|
133
133
|
<p>At runtime:</p>
|
134
134
|
|
135
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier
|
135
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_my_schema'>my_schema</span><span class='period'>.</span><span class='id identifier rubyid_validate!'>validate!</span><span class='lparen'>(</span>
|
136
136
|
<span class='comment'># Your data goes here
|
137
137
|
</span><span class='rparen'>)</span>
|
138
138
|
</code></pre>
|
@@ -161,7 +161,7 @@ this:</p>
|
|
161
161
|
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_s'>s</span> <span class='op'>=</span> <span class='const'>Schema</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
|
162
162
|
<span class='id identifier rubyid_type'>type</span> <span class='symbol'>:integer</span>
|
163
163
|
<span class='id identifier rubyid_type'>type</span> <span class='symbol'>:hash</span> <span class='kw'>do</span>
|
164
|
-
<span class='id identifier rubyid_req'>req</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>
|
164
|
+
<span class='id identifier rubyid_req'>req</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>present</span><span class='tstring_end'>'</span></span> <span class='kw'>do</span>
|
165
165
|
<span class='id identifier rubyid_type'>type</span> <span class='symbol'>:boolean</span>
|
166
166
|
<span class='kw'>end</span>
|
167
167
|
<span class='kw'>end</span>
|
@@ -235,7 +235,7 @@ proc returns false."</p>
|
|
235
235
|
|
236
236
|
<p>The corresponding schema would look as follows:</p>
|
237
237
|
|
238
|
-
<pre class="code ruby"><code class="ruby"><span class='const'>
|
238
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>Schema</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
|
239
239
|
<span class='id identifier rubyid_type'>type</span> <span class='symbol'>:integer</span><span class='comma'>,</span> <span class='label'>if:</span> <span class='id identifier rubyid_proc'>proc</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_data'>data</span><span class='op'>|</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_odd?'>odd?</span> <span class='rbrace'>}</span><span class='comma'>,</span> <span class='label'>max:</span> <span class='int'>15</span>
|
240
240
|
<span class='id identifier rubyid_type'>type</span> <span class='symbol'>:integer</span>
|
241
241
|
<span class='kw'>end</span>
|
@@ -256,8 +256,8 @@ the type checking, meaning that it only gets executed if the data has the right
|
|
256
256
|
type and the proc in <code>if</code> (if any) has returned true.</p>
|
257
257
|
|
258
258
|
<p>The proc passed to the <code>check</code> option is given the data being analyzed. It is to
|
259
|
-
return true if the data passes the custom check. If it returns false
|
260
|
-
considers the data to be invalid.</p>
|
259
|
+
return true if the data passes the custom check. If it returns false or an error
|
260
|
+
message as a string, Schemacop considers the data to be invalid.</p>
|
261
261
|
|
262
262
|
<p>The following example illustrates the use of the option <code>check</code>: Consider a
|
263
263
|
scenario in which you want the following rule set:</p>
|
@@ -278,10 +278,19 @@ scenario in which you want the following rule set:</p>
|
|
278
278
|
<p>The above Type Line has type <code>:string</code> and two options (<code>min</code> and <code>check</code>). The
|
279
279
|
option <code>min</code> is supported by the <code>:string</code> validator (covered later).</p>
|
280
280
|
|
281
|
+
<p>You can also specify a custom error message by returning a string:</p>
|
282
|
+
|
283
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>Schema</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
|
284
|
+
<span class='id identifier rubyid_type'>type</span> <span class='symbol'>:integer</span><span class='comma'>,</span> <span class='label'>check:</span> <span class='id identifier rubyid_proc'>proc</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span> <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_even?'>even?</span> <span class='op'>?</span> <span class='kw'>true</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Custom error</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span>
|
285
|
+
<span class='kw'>end</span>
|
286
|
+
</code></pre>
|
287
|
+
|
288
|
+
<p>This will include <code>Custom error</code> in the validation error message.</p>
|
289
|
+
|
281
290
|
<h3>Field Line</h3>
|
282
291
|
|
283
|
-
<p>Inside a Type Line of type <code>:hash</code
|
284
|
-
|
292
|
+
<p>Inside a Type Line of type <code>:hash</code>, you may specify an arbitrary number of field
|
293
|
+
lines (one for each key-value pair you want to be in the hash).</p>
|
285
294
|
|
286
295
|
<p>Field Lines start with one of the following six identifiers: <code>req</code>, <code>req?</code>,
|
287
296
|
<code>req!</code>, <code>opt</code>, <code>opt?</code> or <code>opt!</code>:</p>
|
@@ -327,12 +336,41 @@ non-nil field of type Integer or Date under the key <code>:age</code>.</p>
|
|
327
336
|
<p>You might find the notation cumbersome, and you'd be right to say so. Luckily
|
328
337
|
there are plenty of short forms available which we will see below.</p>
|
329
338
|
|
339
|
+
<h4>Handling hashes with indifferent access</h4>
|
340
|
+
|
341
|
+
<p>Schemacop has special handling for objects of the class
|
342
|
+
<code>ActiveSupport::HashWithIndifferentAccess</code>: You may specify the keys as symbols
|
343
|
+
or strings, and Schemacop will handle the conversion necessary for proper
|
344
|
+
validation internally. Note that if you define the same key as string and
|
345
|
+
symbol, it will throw a <code>ValidationError</code> <a href="#exceptions">exception</a> when asked to
|
346
|
+
validate a hash with indifferent access.</p>
|
347
|
+
|
348
|
+
<p>Thus, the following two schema definitions are equivalent when validating a hash
|
349
|
+
with indifferent access:</p>
|
350
|
+
|
351
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>Schema</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
|
352
|
+
<span class='id identifier rubyid_type'>type</span> <span class='symbol'>:hash</span> <span class='kw'>do</span>
|
353
|
+
<span class='id identifier rubyid_req'>req</span> <span class='symbol'>:name</span> <span class='kw'>do</span>
|
354
|
+
<span class='id identifier rubyid_type'>type</span> <span class='symbol'>:string</span>
|
355
|
+
<span class='kw'>end</span>
|
356
|
+
<span class='kw'>end</span>
|
357
|
+
<span class='kw'>end</span>
|
358
|
+
|
359
|
+
<span class='const'>Schema</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
|
360
|
+
<span class='id identifier rubyid_type'>type</span> <span class='symbol'>:hash</span> <span class='kw'>do</span>
|
361
|
+
<span class='id identifier rubyid_req'>req</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>name</span><span class='tstring_end'>'</span></span> <span class='kw'>do</span>
|
362
|
+
<span class='id identifier rubyid_type'>type</span> <span class='symbol'>:string</span>
|
363
|
+
<span class='kw'>end</span>
|
364
|
+
<span class='kw'>end</span>
|
365
|
+
<span class='kw'>end</span>
|
366
|
+
</code></pre>
|
367
|
+
|
330
368
|
<h2>Types</h2>
|
331
369
|
|
332
|
-
<p>
|
370
|
+
<p>Types are defined via their validators, which is a class under <code>validator/</code>.
|
371
|
+
Each validator is sourced by <code>schemacop.rb</code>.</p>
|
333
372
|
|
334
|
-
|
335
|
-
another `your_validator.rb` class under `validator/`): -->
|
373
|
+
<p>The following types are supported by Schemacop by default:</p>
|
336
374
|
|
337
375
|
<ul>
|
338
376
|
<li><p><code>:boolean</code> accepts a Ruby TrueClass or FalseClass instance.</p></li>
|
@@ -356,31 +394,39 @@ another `your_validator.rb` class under `validator/`): -->
|
|
356
394
|
<ul>
|
357
395
|
<li>supported options: <code>min</code>, <code>max</code> (bounds for string length)</li>
|
358
396
|
</ul></li>
|
359
|
-
<li><p><code>:
|
397
|
+
<li><p><code>:symbol</code> accepts a Ruby Symbol.</p></li>
|
398
|
+
<li><p><code>:object</code> accepts an arbitrary Ruby object (any object if no option is given).</p></li>
|
399
|
+
</ul>
|
400
|
+
|
401
|
+
<p>Supported options:</p>
|
360
402
|
|
361
403
|
<ul>
|
362
|
-
<li
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
<
|
404
|
+
<li><p><code>classes</code>: Ruby class (or an array of them) that will be the only recognized
|
405
|
+
filters. Unlike other options, this one affects not the validation but the
|
406
|
+
type recognition, meaning that you can have multiple Type Lines with
|
407
|
+
different <code>classes</code> option for the same field, each having its own
|
408
|
+
validation (e.g. through the option <code>check</code>).</p></li>
|
409
|
+
<li><p><code>strict</code>: Boolean option, defaults to true. If set to false, the validator
|
410
|
+
also allows derived classes of those specified with <code>classes</code>.</p>
|
369
411
|
|
370
412
|
<ul>
|
371
|
-
<li
|
372
|
-
<li>accepts a block with an arbitrary number of Type Lines.</li>
|
373
|
-
<li>TODO no lookahead for different arrays, see
|
374
|
-
validator_array_test#test_multiple_arrays</li>
|
413
|
+
<li><code>:array</code> accepts a Ruby Array.</li>
|
375
414
|
</ul></li>
|
376
|
-
<li><p
|
415
|
+
<li><p>supported options: <code>min</code>, <code>max</code> (bounds for array size) and <code>nil</code>: TODO</p></li>
|
416
|
+
<li><p>accepts a block with an arbitrary number of Type Lines.</p></li>
|
417
|
+
<li><p>TODO no lookahead for different arrays, see
|
418
|
+
validator_array_test#test_multiple_arrays</p>
|
377
419
|
|
378
420
|
<ul>
|
379
|
-
<li>accepts a
|
421
|
+
<li><code>:hash</code> accepts a Ruby Hash or an <code>ActiveSupport::HashWithIndifferentAccess</code>.</li>
|
380
422
|
</ul></li>
|
381
|
-
<li><p
|
423
|
+
<li><p>accepts a block with an arbitrary number of Field Lines.</p>
|
424
|
+
|
425
|
+
<ul>
|
426
|
+
<li><code>:nil</code>: accepts a Ruby NilClass instance. If you want to allow <code>nil</code> as a
|
382
427
|
value in a field, see above for the usage of the suffixes <code>-!</code> and <code>-?</code> for
|
383
|
-
Field Lines.</
|
428
|
+
Field Lines.</li>
|
429
|
+
</ul></li>
|
384
430
|
</ul>
|
385
431
|
|
386
432
|
<p>All types support the options <code>if</code> and <code>check</code> (see the section about Type Lines
|
@@ -585,13 +631,13 @@ to <a href="http://www.subgit.com/">SubGit</a> for their great open source licen
|
|
585
631
|
|
586
632
|
<h2>Copyright</h2>
|
587
633
|
|
588
|
-
<p>Copyright (c)
|
634
|
+
<p>Copyright (c) 2019 Sitrox. See <code>LICENSE</code> for further details.</p>
|
589
635
|
</div></div>
|
590
636
|
|
591
637
|
<div id="footer">
|
592
|
-
Generated on
|
638
|
+
Generated on Thu Sep 26 13:19:46 2019 by
|
593
639
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
594
|
-
0.9.
|
640
|
+
0.9.20 (ruby-2.6.2).
|
595
641
|
</div>
|
596
642
|
|
597
643
|
</div>
|