kwalify 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +232 -0
- data/MIT-LICENSE +20 -0
- data/README.txt +16 -19
- data/bin/kwalify +3 -3
- data/contrib/inline-require +6 -4
- data/contrib/kwalify +3719 -2427
- data/doc-api/classes/CommandOptionError.html +17 -17
- data/doc-api/classes/CommandOptionParser.html +63 -63
- data/doc-api/classes/Kwalify.html +29 -7
- data/doc-api/classes/Kwalify/AssertionError.html +9 -9
- data/doc-api/classes/Kwalify/BaseError.html +72 -71
- data/doc-api/classes/Kwalify/BaseParser.html +461 -0
- data/doc-api/classes/Kwalify/CommandOptionError.html +11 -11
- data/doc-api/classes/Kwalify/ErrorHelper.html +51 -46
- data/doc-api/classes/Kwalify/HashInterface.html +13 -135
- data/doc-api/classes/Kwalify/Json.html +105 -0
- data/doc-api/classes/Kwalify/Main.html +129 -126
- data/doc-api/classes/Kwalify/MetaValidator.html +248 -232
- data/doc-api/classes/Kwalify/Parser.html +12 -12
- data/doc-api/classes/Kwalify/PlainYamlParser.html +166 -163
- data/doc-api/classes/Kwalify/PlainYamlParser/Alias.html +11 -11
- data/doc-api/classes/Kwalify/Rule.html +152 -130
- data/doc-api/classes/Kwalify/SchemaError.html +10 -10
- data/doc-api/classes/Kwalify/SyntaxError.html +185 -0
- data/doc-api/classes/Kwalify/Types.html +26 -25
- data/doc-api/classes/Kwalify/Util.html +389 -0
- data/doc-api/classes/Kwalify/Util/HashLike.html +246 -0
- data/doc-api/classes/Kwalify/Util/OrderedHash.html +330 -0
- data/doc-api/classes/Kwalify/ValidationError.html +10 -10
- data/doc-api/classes/Kwalify/Validator.html +153 -86
- data/doc-api/classes/Kwalify/Yaml.html +181 -0
- data/doc-api/classes/Kwalify/Yaml/Parser.html +1538 -0
- data/doc-api/classes/Kwalify/YamlParser.html +190 -183
- data/doc-api/classes/Kwalify/YamlSyntaxError.html +8 -57
- data/doc-api/created.rid +1 -1
- data/doc-api/files/__/README_txt.html +17 -22
- data/doc-api/files/kwalify/errors_rb.html +2 -2
- data/doc-api/files/kwalify/main_rb.html +4 -3
- data/doc-api/files/kwalify/messages_rb.html +2 -2
- data/doc-api/files/kwalify/meta-validator_rb.html +3 -3
- data/doc-api/files/kwalify/{util/yaml-helper_rb.html → parser/base_rb.html} +8 -6
- data/doc-api/files/kwalify/parser/yaml_rb.html +117 -0
- data/doc-api/files/kwalify/rule_rb.html +2 -2
- data/doc-api/files/kwalify/types_rb.html +2 -2
- data/doc-api/files/kwalify/util/assert-text-equal_rb.html +2 -2
- data/doc-api/files/kwalify/util/hash-interface_rb.html +9 -2
- data/doc-api/files/kwalify/util/hashlike_rb.html +107 -0
- data/doc-api/files/kwalify/util/option-parser_rb.html +2 -2
- data/doc-api/files/kwalify/util/ordered-hash_rb.html +107 -0
- data/doc-api/files/kwalify/util/testcase-helper_rb.html +2 -2
- data/doc-api/files/kwalify/util_rb.html +107 -0
- data/doc-api/files/kwalify/validator_rb.html +2 -2
- data/doc-api/files/kwalify/yaml-parser_rb.html +2 -2
- data/doc-api/files/kwalify_rb.html +3 -2
- data/doc-api/fr_class_index.html +8 -1
- data/doc-api/fr_file_index.html +5 -1
- data/doc-api/fr_method_index.html +128 -69
- data/doc/img/fig01.png +0 -0
- data/doc/users-guide.html +882 -717
- data/examples/address-book/address-book.schema.yaml +2 -2
- data/examples/data-binding/BABEL.data.yaml +63 -0
- data/examples/data-binding/BABEL.schema.yaml +31 -0
- data/examples/data-binding/Makefile +8 -0
- data/examples/data-binding/Rakefile +13 -0
- data/examples/data-binding/main.rb +27 -0
- data/examples/invoice/invoice.schema.yaml +3 -3
- data/examples/tapkit/tapkit.schema.yaml +2 -2
- data/lib/kwalify.rb +41 -4
- data/lib/kwalify/errors.rb +118 -96
- data/lib/kwalify/kwalify.schema.yaml +58 -0
- data/lib/kwalify/main.rb +384 -377
- data/lib/kwalify/messages.rb +41 -27
- data/lib/kwalify/meta-validator.rb +251 -331
- data/lib/kwalify/parser/base.rb +127 -0
- data/lib/kwalify/parser/yaml.rb +837 -0
- data/lib/kwalify/rule.rb +545 -487
- data/lib/kwalify/templates/genclass-java.eruby +189 -162
- data/lib/kwalify/templates/genclass-php.eruby +104 -0
- data/lib/kwalify/templates/genclass-ruby.eruby +95 -66
- data/lib/kwalify/types.rb +107 -106
- data/lib/kwalify/util.rb +157 -0
- data/lib/kwalify/util/assert-text-equal.rb +33 -31
- data/lib/kwalify/util/hash-interface.rb +11 -30
- data/lib/kwalify/util/hashlike.rb +51 -0
- data/lib/kwalify/util/option-parser.rb +144 -144
- data/lib/kwalify/util/ordered-hash.rb +57 -0
- data/lib/kwalify/util/testcase-helper.rb +3 -3
- data/lib/kwalify/validator.rb +267 -212
- data/lib/kwalify/yaml-parser.rb +822 -768
- data/setup.rb +861 -607
- data/test/Rookbook.yaml +10 -0
- data/test/{tmp.dir/Context.java → data/users-guide/AddressBook.java.expected} +11 -11
- data/test/data/users-guide/BABEL.data.yaml +24 -0
- data/test/data/users-guide/BABEL.schema.yaml +30 -0
- data/test/data/users-guide/ExampleAddressBook.java +47 -0
- data/test/{tmp.dir/Group.java → data/users-guide/Group.java.expected} +2 -11
- data/test/data/users-guide/Person.java.expected +44 -0
- data/test/data/users-guide/address_book.rb +52 -0
- data/test/data/users-guide/address_book.schema.yaml +28 -0
- data/test/data/users-guide/address_book.yaml +27 -0
- data/test/data/users-guide/answers-schema.yaml +12 -0
- data/test/data/users-guide/answers-validator.rb +52 -0
- data/test/data/users-guide/babel_genclass.result +26 -0
- data/test/data/users-guide/config.schema.yaml +7 -0
- data/test/data/users-guide/config.yaml +4 -0
- data/test/{tmp.dir/silent1.document → data/users-guide/document01a.yaml} +0 -0
- data/test/data/users-guide/document01b.yaml +3 -0
- data/test/data/users-guide/document02a.yaml +4 -0
- data/test/data/users-guide/document02b.yaml +4 -0
- data/test/data/users-guide/document03a.yaml +6 -0
- data/test/data/users-guide/document03b.yaml +6 -0
- data/test/data/users-guide/document04a.yaml +9 -0
- data/test/data/users-guide/document04b.yaml +9 -0
- data/test/data/users-guide/document05a.yaml +11 -0
- data/test/data/users-guide/document05b.yaml +12 -0
- data/test/data/users-guide/document06a.yaml +15 -0
- data/test/data/users-guide/document06b.yaml +16 -0
- data/test/data/users-guide/document07a.yaml +9 -0
- data/test/data/users-guide/document07b.yaml +7 -0
- data/test/data/users-guide/document12a.json +10 -0
- data/test/data/users-guide/document12b.json +6 -0
- data/test/data/users-guide/document13a.yaml +17 -0
- data/test/data/users-guide/document14a.yaml +3 -0
- data/test/data/users-guide/document14b.yaml +3 -0
- data/test/data/users-guide/document15a.yaml +6 -0
- data/test/data/users-guide/document15b.yaml +5 -0
- data/test/data/users-guide/example_address_book.rb +10 -0
- data/test/data/users-guide/example_address_book_java.result +32 -0
- data/test/data/users-guide/example_address_book_ruby.result +31 -0
- data/test/data/users-guide/genclass_java.result +4 -0
- data/test/data/users-guide/howto-validation-with-parsing.rb +28 -0
- data/test/data/users-guide/howto-validation.rb +25 -0
- data/test/data/users-guide/howto3.rb +6 -0
- data/test/data/users-guide/howto3.result +5 -0
- data/test/data/users-guide/howto3.yaml +8 -0
- data/test/data/users-guide/howto5_databinding.result +111 -0
- data/test/data/users-guide/invalid01.result +3 -0
- data/test/data/users-guide/invalid02.result +5 -0
- data/test/data/users-guide/invalid03.result +5 -0
- data/test/data/users-guide/invalid04.result +4 -0
- data/test/data/users-guide/invalid05.result +11 -0
- data/test/data/users-guide/invalid06.result +4 -0
- data/test/data/users-guide/invalid07.result +3 -0
- data/test/data/users-guide/invalid08.result +3 -0
- data/test/data/users-guide/invalid12.json +8 -0
- data/test/data/users-guide/invalid14.result +4 -0
- data/test/data/users-guide/invalid15.result +4 -0
- data/test/data/users-guide/loadbabel.rb +27 -0
- data/test/data/users-guide/loadconfig.rb +15 -0
- data/test/data/users-guide/loadconfig.result +2 -0
- data/test/data/users-guide/models.rb +22 -0
- data/test/data/users-guide/option_ha.result +6 -0
- data/test/data/users-guide/option_ha_genclass_java.result +7 -0
- data/test/{tmp.dir/meta1.schema → data/users-guide/schema01.yaml} +0 -0
- data/test/data/users-guide/schema02.yaml +12 -0
- data/test/data/users-guide/schema03.yaml +9 -0
- data/test/data/users-guide/schema04.yaml +20 -0
- data/test/data/users-guide/schema05.yaml +29 -0
- data/test/data/users-guide/schema06.yaml +11 -0
- data/test/data/users-guide/schema12.json +12 -0
- data/test/data/users-guide/schema13.yaml +13 -0
- data/test/data/users-guide/schema14.yaml +5 -0
- data/test/data/users-guide/schema15.yaml +21 -0
- data/test/data/users-guide/valid01.result +2 -0
- data/test/data/users-guide/valid02.result +2 -0
- data/test/data/users-guide/valid03.result +2 -0
- data/test/data/users-guide/valid04.result +2 -0
- data/test/data/users-guide/valid05.result +2 -0
- data/test/data/users-guide/valid06.result +2 -0
- data/test/data/users-guide/valid07.result +2 -0
- data/test/data/users-guide/valid08.result +2 -0
- data/test/data/users-guide/valid12.result +2 -0
- data/test/data/users-guide/valid13.result +2 -0
- data/test/data/users-guide/valid14.result +2 -0
- data/test/data/users-guide/valid15.result +2 -0
- data/test/data/users-guide/validate08.rb +37 -0
- data/test/test-action.rb +78 -0
- data/test/test-action.yaml +738 -0
- data/test/test-databinding.rb +80 -0
- data/test/test-databinding.yaml +301 -0
- data/test/test-main.rb +129 -150
- data/test/test-main.yaml +126 -321
- data/test/test-metavalidator.rb +47 -47
- data/test/test-metavalidator.yaml +77 -21
- data/test/test-parser-yaml.rb +57 -0
- data/test/test-parser-yaml.yaml +1749 -0
- data/test/test-rule.rb +14 -15
- data/test/test-rule.yaml +6 -3
- data/test/test-users-guide.rb +75 -0
- data/test/test-validator.rb +77 -52
- data/test/test-validator.yaml +168 -6
- data/test/test-yaml-parser.rb +47 -0
- data/test/{test-yamlparser.yaml → test-yaml-parser.yaml} +159 -52
- data/test/test.rb +37 -21
- metadata +136 -37
- data/COPYING +0 -340
- data/ChangeLog +0 -70
- data/doc-api/classes/YamlHelper.html +0 -259
- data/lib/kwalify/util/yaml-helper.rb +0 -82
- data/test/test-yamlparser.rb +0 -58
- data/test/tmp.dir/User.java +0 -43
- data/test/tmp.dir/action1.document +0 -18
- data/test/tmp.dir/action1.schema +0 -32
- data/test/tmp.dir/action2.document +0 -18
- data/test/tmp.dir/action2.schema +0 -32
- data/test/tmp.dir/emacs.document +0 -6
- data/test/tmp.dir/emacs.schema +0 -6
- data/test/tmp.dir/meta1.document +0 -0
- data/test/tmp.dir/meta2.document +0 -0
- data/test/tmp.dir/meta2.schema +0 -3
- data/test/tmp.dir/silent1.schema +0 -3
- data/test/tmp.dir/silent2.document +0 -7
- data/test/tmp.dir/silent2.schema +0 -3
- data/test/tmp.dir/stream.invalid +0 -8
- data/test/tmp.dir/stream.schema +0 -3
- data/test/tmp.dir/stream.valid +0 -8
- data/test/tmp.dir/untabify.document +0 -5
- data/test/tmp.dir/untabify.schema +0 -10
- data/todo.txt +0 -34
@@ -83,18 +83,18 @@
|
|
83
83
|
ex.
|
84
84
|
</p>
|
85
85
|
<pre>
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
86
|
+
command = File.basename($0)
|
87
|
+
begin
|
88
|
+
main = Kwalify::Main.new(command)
|
89
|
+
s = main.execute
|
90
|
+
print s if s
|
91
|
+
rescue Kwalify::CommandOptionError => ex
|
92
|
+
$stderr.puts "ERROR: #{ex.message}"
|
93
|
+
exit 1
|
94
|
+
rescue Kwalify::KwalifyError => ex
|
95
|
+
$stderr.puts "ERROR: #{ex.message}"
|
96
|
+
exit 1
|
97
|
+
end
|
98
98
|
</pre>
|
99
99
|
|
100
100
|
</div>
|
@@ -106,11 +106,11 @@ ex.
|
|
106
106
|
<h3 class="section-bar">Methods</h3>
|
107
107
|
|
108
108
|
<div class="name-list">
|
109
|
-
<a href="#
|
110
|
-
<a href="#
|
111
|
-
<a href="#
|
112
|
-
<a href="#
|
113
|
-
<a href="#
|
109
|
+
<a href="#M000088">_inspect</a>
|
110
|
+
<a href="#M000087">debug?</a>
|
111
|
+
<a href="#M000089">execute</a>
|
112
|
+
<a href="#M000090">main</a>
|
113
|
+
<a href="#M000086">new</a>
|
114
114
|
</div>
|
115
115
|
</div>
|
116
116
|
|
@@ -132,71 +132,73 @@ ex.
|
|
132
132
|
<div id="methods">
|
133
133
|
<h3 class="section-bar">Public Class methods</h3>
|
134
134
|
|
135
|
-
<div id="method-
|
136
|
-
<a name="
|
135
|
+
<div id="method-M000090" class="method-detail">
|
136
|
+
<a name="M000090"></a>
|
137
137
|
|
138
138
|
<div class="method-heading">
|
139
|
-
<a href="#
|
139
|
+
<a href="#M000090" class="method-signature">
|
140
140
|
<span class="method-name">main</span><span class="method-args">(command, argv=ARGV)</span>
|
141
141
|
</a>
|
142
142
|
</div>
|
143
143
|
|
144
144
|
<div class="method-description">
|
145
145
|
<p><a class="source-toggle" href="#"
|
146
|
-
onclick="toggleCode('
|
147
|
-
<div class="method-source-code" id="
|
146
|
+
onclick="toggleCode('M000090-source');return false;">[Source]</a></p>
|
147
|
+
<div class="method-source-code" id="M000090-source">
|
148
148
|
<pre>
|
149
|
-
<span class="ruby-comment cmt"># File kwalify/main.rb, line
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
149
|
+
<span class="ruby-comment cmt"># File kwalify/main.rb, line 121</span>
|
150
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">main</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">argv</span>=<span class="ruby-constant">ARGV</span>)
|
151
|
+
<span class="ruby-keyword kw">begin</span>
|
152
|
+
<span class="ruby-identifier">main</span> = <span class="ruby-constant">Kwalify</span><span class="ruby-operator">::</span><span class="ruby-constant">Main</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">command</span>)
|
153
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-identifier">main</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">argv</span>)
|
154
|
+
<span class="ruby-identifier">print</span> <span class="ruby-identifier">s</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>
|
155
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Kwalify</span><span class="ruby-operator">::</span><span class="ruby-constant">CommandOptionError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
156
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">ex</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">main</span>.<span class="ruby-identifier">debug?</span>
|
157
|
+
<span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">ex</span>.<span class="ruby-identifier">message</span>
|
158
|
+
<span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
|
159
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Kwalify</span><span class="ruby-operator">::</span><span class="ruby-constant">KwalifyError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
160
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">ex</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">main</span>.<span class="ruby-identifier">debug?</span>
|
161
|
+
<span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"ERROR: #{ex.to_s}"</span>
|
162
|
+
<span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
|
163
|
+
<span class="ruby-comment cmt">#rescue => ex</span>
|
164
|
+
<span class="ruby-comment cmt"># if main.debug?</span>
|
165
|
+
<span class="ruby-comment cmt"># raise ex</span>
|
166
|
+
<span class="ruby-comment cmt"># else</span>
|
167
|
+
<span class="ruby-comment cmt"># $stderr.puts ex.message</span>
|
168
|
+
<span class="ruby-comment cmt"># exit 1</span>
|
169
|
+
<span class="ruby-comment cmt"># end</span>
|
169
170
|
<span class="ruby-keyword kw">end</span>
|
171
|
+
<span class="ruby-keyword kw">end</span>
|
170
172
|
</pre>
|
171
173
|
</div>
|
172
174
|
</div>
|
173
175
|
</div>
|
174
176
|
|
175
|
-
<div id="method-
|
176
|
-
<a name="
|
177
|
+
<div id="method-M000086" class="method-detail">
|
178
|
+
<a name="M000086"></a>
|
177
179
|
|
178
180
|
<div class="method-heading">
|
179
|
-
<a href="#
|
181
|
+
<a href="#M000086" class="method-signature">
|
180
182
|
<span class="method-name">new</span><span class="method-args">(command=nil)</span>
|
181
183
|
</a>
|
182
184
|
</div>
|
183
185
|
|
184
186
|
<div class="method-description">
|
185
187
|
<p><a class="source-toggle" href="#"
|
186
|
-
onclick="toggleCode('
|
187
|
-
<div class="method-source-code" id="
|
188
|
+
onclick="toggleCode('M000086-source');return false;">[Source]</a></p>
|
189
|
+
<div class="method-source-code" id="M000086-source">
|
188
190
|
<pre>
|
189
191
|
<span class="ruby-comment cmt"># File kwalify/main.rb, line 45</span>
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
<span class="ruby-keyword kw">end</span>
|
192
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">command</span>=<span class="ruby-keyword kw">nil</span>)
|
193
|
+
<span class="ruby-ivar">@command</span> = <span class="ruby-identifier">command</span> <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">$0</span>)
|
194
|
+
<span class="ruby-ivar">@options</span> = {}
|
195
|
+
<span class="ruby-ivar">@properties</span> = {}
|
196
|
+
<span class="ruby-ivar">@template_path</span> = []
|
197
|
+
<span class="ruby-identifier">$:</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
|
198
|
+
<span class="ruby-identifier">tpath</span> = <span class="ruby-node">"#{path}/kwalify/templates"</span>
|
199
|
+
<span class="ruby-ivar">@template_path</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">tpath</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?d</span>, <span class="ruby-identifier">tpath</span>)
|
199
200
|
<span class="ruby-keyword kw">end</span>
|
201
|
+
<span class="ruby-keyword kw">end</span>
|
200
202
|
</pre>
|
201
203
|
</div>
|
202
204
|
</div>
|
@@ -204,118 +206,119 @@ ex.
|
|
204
206
|
|
205
207
|
<h3 class="section-bar">Public Instance methods</h3>
|
206
208
|
|
207
|
-
<div id="method-
|
208
|
-
<a name="
|
209
|
+
<div id="method-M000088" class="method-detail">
|
210
|
+
<a name="M000088"></a>
|
209
211
|
|
210
212
|
<div class="method-heading">
|
211
|
-
<a href="#
|
213
|
+
<a href="#M000088" class="method-signature">
|
212
214
|
<span class="method-name">_inspect</span><span class="method-args">()</span>
|
213
215
|
</a>
|
214
216
|
</div>
|
215
217
|
|
216
218
|
<div class="method-description">
|
217
219
|
<p><a class="source-toggle" href="#"
|
218
|
-
onclick="toggleCode('
|
219
|
-
<div class="method-source-code" id="
|
220
|
+
onclick="toggleCode('M000088-source');return false;">[Source]</a></p>
|
221
|
+
<div class="method-source-code" id="M000088-source">
|
220
222
|
<pre>
|
221
223
|
<span class="ruby-comment cmt"># File kwalify/main.rb, line 62</span>
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
<span class="ruby-keyword kw">end</span>
|
229
|
-
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"properties:\n"</span>
|
230
|
-
<span class="ruby-ivar">@properties</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">sort_by</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span>}.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
231
|
-
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" - #{key}: #{@properties[key]}\n"</span>
|
232
|
-
<span class="ruby-keyword kw">end</span>
|
233
|
-
<span class="ruby-comment cmt">#sb << "template_path:\n"</span>
|
234
|
-
<span class="ruby-comment cmt">#@template_path.each do |path|</span>
|
235
|
-
<span class="ruby-comment cmt"># sb << " - #{path}\n"</span>
|
236
|
-
<span class="ruby-comment cmt">#end</span>
|
237
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">sb</span>.<span class="ruby-identifier">join</span>
|
224
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_inspect</span>()
|
225
|
+
<span class="ruby-identifier">sb</span> = []
|
226
|
+
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"command: #{@command}\n"</span>
|
227
|
+
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"options:\n"</span>
|
228
|
+
<span class="ruby-ivar">@options</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">sort</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k1</span>,<span class="ruby-identifier">k2</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k1</span>.<span class="ruby-identifier">to_s</span><span class="ruby-operator"><=></span><span class="ruby-identifier">k2</span>.<span class="ruby-identifier">to_s</span> }.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
229
|
+
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" - #{key}: #{@options[key]}\n"</span>
|
238
230
|
<span class="ruby-keyword kw">end</span>
|
231
|
+
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"properties:\n"</span>
|
232
|
+
<span class="ruby-ivar">@properties</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">sort_by</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span>}.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
233
|
+
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" - #{key}: #{@properties[key]}\n"</span>
|
234
|
+
<span class="ruby-keyword kw">end</span>
|
235
|
+
<span class="ruby-comment cmt">#sb << "template_path:\n"</span>
|
236
|
+
<span class="ruby-comment cmt">#@template_path.each do |path|</span>
|
237
|
+
<span class="ruby-comment cmt"># sb << " - #{path}\n"</span>
|
238
|
+
<span class="ruby-comment cmt">#end</span>
|
239
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">sb</span>.<span class="ruby-identifier">join</span>
|
240
|
+
<span class="ruby-keyword kw">end</span>
|
239
241
|
</pre>
|
240
242
|
</div>
|
241
243
|
</div>
|
242
244
|
</div>
|
243
245
|
|
244
|
-
<div id="method-
|
245
|
-
<a name="
|
246
|
+
<div id="method-M000087" class="method-detail">
|
247
|
+
<a name="M000087"></a>
|
246
248
|
|
247
249
|
<div class="method-heading">
|
248
|
-
<a href="#
|
250
|
+
<a href="#M000087" class="method-signature">
|
249
251
|
<span class="method-name">debug?</span><span class="method-args">()</span>
|
250
252
|
</a>
|
251
253
|
</div>
|
252
254
|
|
253
255
|
<div class="method-description">
|
254
256
|
<p><a class="source-toggle" href="#"
|
255
|
-
onclick="toggleCode('
|
256
|
-
<div class="method-source-code" id="
|
257
|
+
onclick="toggleCode('M000087-source');return false;">[Source]</a></p>
|
258
|
+
<div class="method-source-code" id="M000087-source">
|
257
259
|
<pre>
|
258
260
|
<span class="ruby-comment cmt"># File kwalify/main.rb, line 57</span>
|
259
|
-
|
260
|
-
|
261
|
-
|
261
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug?</span>
|
262
|
+
<span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:debug</span>]
|
263
|
+
<span class="ruby-keyword kw">end</span>
|
262
264
|
</pre>
|
263
265
|
</div>
|
264
266
|
</div>
|
265
267
|
</div>
|
266
268
|
|
267
|
-
<div id="method-
|
268
|
-
<a name="
|
269
|
+
<div id="method-M000089" class="method-detail">
|
270
|
+
<a name="M000089"></a>
|
269
271
|
|
270
272
|
<div class="method-heading">
|
271
|
-
<a href="#
|
273
|
+
<a href="#M000089" class="method-signature">
|
272
274
|
<span class="method-name">execute</span><span class="method-args">(argv=ARGV)</span>
|
273
275
|
</a>
|
274
276
|
</div>
|
275
277
|
|
276
278
|
<div class="method-description">
|
277
279
|
<p><a class="source-toggle" href="#"
|
278
|
-
onclick="toggleCode('
|
279
|
-
<div class="method-source-code" id="
|
280
|
+
onclick="toggleCode('M000089-source');return false;">[Source]</a></p>
|
281
|
+
<div class="method-source-code" id="M000089-source">
|
280
282
|
<pre>
|
281
283
|
<span class="ruby-comment cmt"># File kwalify/main.rb, line 81</span>
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span> <span class="ruby-comment cmt"># or return (s == nil || s.empty?) ? nil : s</span>
|
284
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">execute</span>(<span class="ruby-identifier">argv</span>=<span class="ruby-constant">ARGV</span>)
|
285
|
+
<span class="ruby-comment cmt">## parse command-line options</span>
|
286
|
+
<span class="ruby-identifier">filenames</span> = <span class="ruby-identifier">_parse_argv</span>(<span class="ruby-identifier">argv</span>)
|
287
|
+
|
288
|
+
<span class="ruby-comment cmt">## help or version</span>
|
289
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:help</span>] <span class="ruby-operator">||</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:version</span>]
|
290
|
+
<span class="ruby-identifier">action</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:action</span>]
|
291
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-value str">''</span>
|
292
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">_version</span>() <span class="ruby-operator"><<</span> <span class="ruby-value str">"\n"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:version</span>]
|
293
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">_usage</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:help</span>] <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">action</span>
|
294
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">_describe_properties</span>(<span class="ruby-identifier">action</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:help</span>] <span class="ruby-operator">&&</span> <span class="ruby-identifier">action</span>
|
295
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">s</span>
|
296
|
+
<span class="ruby-keyword kw">return</span>
|
297
|
+
<span class="ruby-keyword kw">end</span>
|
298
|
+
|
299
|
+
<span class="ruby-comment cmt"># validation</span>
|
300
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:meta2</span>]
|
301
|
+
<span class="ruby-identifier">validate_schemafiles2</span>(<span class="ruby-identifier">filenames</span>)
|
302
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:meta</span>]
|
303
|
+
<span class="ruby-identifier">validate_schemafiles</span>(<span class="ruby-identifier">filenames</span>)
|
304
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:action</span>]
|
305
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:schema</span>]
|
306
|
+
<span class="ruby-comment cmt">#* key=:command_option_actionnoschema msg="schema filename is not specified."</span>
|
307
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-identifier">:command_option_actionnoschema</span>, <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:action</span>])
|
308
|
+
<span class="ruby-keyword kw">end</span>
|
309
|
+
<span class="ruby-identifier">perform_action</span>(<span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:action</span>], <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:schema</span>])
|
310
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:schema</span>]
|
311
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:debug</span>]
|
312
|
+
<span class="ruby-identifier">inspect_schema</span>(<span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:schema</span>])
|
313
|
+
<span class="ruby-keyword kw">else</span>
|
314
|
+
<span class="ruby-identifier">validate_files</span>(<span class="ruby-identifier">filenames</span>, <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:schema</span>])
|
315
|
+
<span class="ruby-keyword kw">end</span>
|
316
|
+
<span class="ruby-keyword kw">else</span>
|
317
|
+
<span class="ruby-comment cmt">#* key=:command_option_noaction msg="command-line option '-f' or '-m' required."</span>
|
318
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-identifier">:command_option_noaction</span>, <span class="ruby-ivar">@command</span>)
|
318
319
|
<span class="ruby-keyword kw">end</span>
|
320
|
+
<span class="ruby-keyword kw">return</span>
|
321
|
+
<span class="ruby-keyword kw">end</span>
|
319
322
|
</pre>
|
320
323
|
</div>
|
321
324
|
</div>
|
@@ -104,9 +104,9 @@ ex.
|
|
104
104
|
<h3 class="section-bar">Methods</h3>
|
105
105
|
|
106
106
|
<div class="name-list">
|
107
|
-
<a href="#
|
108
|
-
<a href="#
|
109
|
-
<a href="#
|
107
|
+
<a href="#M000121">instance</a>
|
108
|
+
<a href="#M000122">new</a>
|
109
|
+
<a href="#M000123">validate_hook</a>
|
110
110
|
</div>
|
111
111
|
</div>
|
112
112
|
|
@@ -126,7 +126,7 @@ ex.
|
|
126
126
|
<tr class="top-aligned-row context-row">
|
127
127
|
<td class="context-item-name">META_SCHEMA</td>
|
128
128
|
<td>=</td>
|
129
|
-
<td class="context-item-value"
|
129
|
+
<td class="context-item-value">File.read(filename)</td>
|
130
130
|
</tr>
|
131
131
|
</table>
|
132
132
|
</div>
|
@@ -141,47 +141,51 @@ ex.
|
|
141
141
|
<div id="methods">
|
142
142
|
<h3 class="section-bar">Public Class methods</h3>
|
143
143
|
|
144
|
-
<div id="method-
|
145
|
-
<a name="
|
144
|
+
<div id="method-M000121" class="method-detail">
|
145
|
+
<a name="M000121"></a>
|
146
146
|
|
147
147
|
<div class="method-heading">
|
148
|
-
<a href="#
|
148
|
+
<a href="#M000121" class="method-signature">
|
149
149
|
<span class="method-name">instance</span><span class="method-args">()</span>
|
150
150
|
</a>
|
151
151
|
</div>
|
152
152
|
|
153
153
|
<div class="method-description">
|
154
154
|
<p><a class="source-toggle" href="#"
|
155
|
-
onclick="toggleCode('
|
156
|
-
<div class="method-source-code" id="
|
155
|
+
onclick="toggleCode('M000121-source');return false;">[Source]</a></p>
|
156
|
+
<div class="method-source-code" id="M000121-source">
|
157
157
|
<pre>
|
158
|
-
<span class="ruby-comment cmt"># File kwalify/meta-validator.rb, line
|
159
|
-
|
160
|
-
|
158
|
+
<span class="ruby-comment cmt"># File kwalify/meta-validator.rb, line 32</span>
|
159
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">instance</span>()
|
160
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@instance</span>
|
161
|
+
<span class="ruby-identifier">schema</span> = <span class="ruby-constant">Kwalify</span><span class="ruby-operator">::</span><span class="ruby-constant">Yaml</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">new</span>().<span class="ruby-identifier">parse</span>(<span class="ruby-constant">META_SCHEMA</span>)
|
162
|
+
<span class="ruby-ivar">@instance</span> = <span class="ruby-constant">MetaValidator</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">schema</span>)
|
161
163
|
<span class="ruby-keyword kw">end</span>
|
164
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@instance</span>
|
165
|
+
<span class="ruby-keyword kw">end</span>
|
162
166
|
</pre>
|
163
167
|
</div>
|
164
168
|
</div>
|
165
169
|
</div>
|
166
170
|
|
167
|
-
<div id="method-
|
168
|
-
<a name="
|
171
|
+
<div id="method-M000122" class="method-detail">
|
172
|
+
<a name="M000122"></a>
|
169
173
|
|
170
174
|
<div class="method-heading">
|
171
|
-
<a href="#
|
175
|
+
<a href="#M000122" class="method-signature">
|
172
176
|
<span class="method-name">new</span><span class="method-args">(schema, &block)</span>
|
173
177
|
</a>
|
174
178
|
</div>
|
175
179
|
|
176
180
|
<div class="method-description">
|
177
181
|
<p><a class="source-toggle" href="#"
|
178
|
-
onclick="toggleCode('
|
179
|
-
<div class="method-source-code" id="
|
182
|
+
onclick="toggleCode('M000122-source');return false;">[Source]</a></p>
|
183
|
+
<div class="method-source-code" id="M000122-source">
|
180
184
|
<pre>
|
181
|
-
<span class="ruby-comment cmt"># File kwalify/meta-validator.rb, line
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
+
<span class="ruby-comment cmt"># File kwalify/meta-validator.rb, line 40</span>
|
186
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">schema</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
187
|
+
<span class="ruby-keyword kw">super</span>
|
188
|
+
<span class="ruby-keyword kw">end</span>
|
185
189
|
</pre>
|
186
190
|
</div>
|
187
191
|
</div>
|
@@ -189,229 +193,241 @@ ex.
|
|
189
193
|
|
190
194
|
<h3 class="section-bar">Public Instance methods</h3>
|
191
195
|
|
192
|
-
<div id="method-
|
193
|
-
<a name="
|
196
|
+
<div id="method-M000123" class="method-detail">
|
197
|
+
<a name="M000123"></a>
|
194
198
|
|
195
199
|
<div class="method-heading">
|
196
|
-
<a href="#
|
200
|
+
<a href="#M000123" class="method-signature">
|
197
201
|
<span class="method-name">validate_hook</span><span class="method-args">(value, rule, path, errors)</span>
|
198
202
|
</a>
|
199
203
|
</div>
|
200
204
|
|
201
205
|
<div class="method-description">
|
202
206
|
<p><a class="source-toggle" href="#"
|
203
|
-
onclick="toggleCode('
|
204
|
-
<div class="method-source-code" id="
|
207
|
+
onclick="toggleCode('M000123-source');return false;">[Source]</a></p>
|
208
|
+
<div class="method-source-code" id="M000123-source">
|
205
209
|
<pre>
|
206
|
-
<span class="ruby-comment cmt"># File kwalify/meta-validator.rb, line
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
<span class="ruby-comment cmt">#end</span>
|
245
|
-
<span class="ruby-comment cmt">#elem_table[elem] = true</span>
|
246
|
-
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">elem</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-identifier">klass</span>)
|
247
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:enum_type_unmatch</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/enum"</span>, <span class="ruby-identifier">elem</span>, [<span class="ruby-constant">Kwalify</span>.<span class="ruby-identifier">word</span>(<span class="ruby-identifier">type</span>)])
|
248
|
-
<span class="ruby-keyword kw">end</span>
|
249
|
-
<span class="ruby-keyword kw">end</span>
|
250
|
-
<span class="ruby-keyword kw">end</span>
|
251
|
-
<span class="ruby-keyword kw">end</span>
|
252
|
-
<span class="ruby-comment cmt">#</span>
|
253
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'assert'</span>)
|
254
|
-
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'assert'</span>]
|
255
|
-
<span class="ruby-comment cmt">#val =~ /\bval\b/ or errors << validate_error(:assert_noval, rule, "#{path}/assert", val)</span>
|
256
|
-
<span class="ruby-keyword kw">begin</span>
|
257
|
-
<span class="ruby-identifier">eval</span> <span class="ruby-node">"proc { |val| #{val} }"</span>
|
258
|
-
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SyntaxError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
259
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:assert_syntaxerr</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/assert"</span>, <span class="ruby-identifier">val</span>)
|
260
|
-
<span class="ruby-keyword kw">end</span>
|
261
|
-
<span class="ruby-keyword kw">end</span>
|
262
|
-
<span class="ruby-comment cmt">#</span>
|
263
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'range'</span>)
|
264
|
-
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'range'</span>]
|
265
|
-
<span class="ruby-identifier">curr_path</span> = <span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"/range"</span>
|
266
|
-
<span class="ruby-comment cmt">#if ! val.is_a?(Hash)</span>
|
267
|
-
<span class="ruby-comment cmt"># errors << validate_error(:range_notmap, rule, curr_path, val)</span>
|
268
|
-
<span class="ruby-comment cmt">#elsif ...</span>
|
269
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">Types</span>.<span class="ruby-identifier">collection_type?</span>(<span class="ruby-identifier">type</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'bool'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'any'</span>
|
270
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_notscalar</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'range:'</span>)
|
271
|
-
<span class="ruby-keyword kw">else</span>
|
272
|
-
<span class="ruby-identifier">val</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">rkey</span>, <span class="ruby-identifier">rval</span><span class="ruby-operator">|</span>
|
273
|
-
<span class="ruby-comment cmt">#case rkey</span>
|
274
|
-
<span class="ruby-comment cmt">#when 'max', 'min', 'max-ex', 'min-ex'</span>
|
275
|
-
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">rval</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-identifier">klass</span>)
|
276
|
-
<span class="ruby-identifier">typename</span> = <span class="ruby-constant">Kwalify</span>.<span class="ruby-identifier">word</span>(<span class="ruby-identifier">type</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span>
|
277
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_type_unmatch</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{curr_path}/#{rkey}"</span>, <span class="ruby-identifier">rval</span>, [<span class="ruby-identifier">typename</span>])
|
278
|
-
<span class="ruby-keyword kw">end</span>
|
279
|
-
<span class="ruby-comment cmt">#else</span>
|
280
|
-
<span class="ruby-comment cmt"># errors << validate_error(:range_undefined, rule, curr_path, "#{rkey}:")</span>
|
281
|
-
<span class="ruby-comment cmt">#end</span>
|
282
|
-
<span class="ruby-keyword kw">end</span>
|
283
|
-
<span class="ruby-keyword kw">end</span>
|
284
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'max'</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'max-ex'</span>)
|
285
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_twomax</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>)
|
286
|
-
<span class="ruby-keyword kw">end</span>
|
287
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'min'</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'min-ex'</span>)
|
288
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_twomin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>)
|
289
|
-
<span class="ruby-keyword kw">end</span>
|
290
|
-
<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min_ex</span> = <span class="ruby-identifier">val</span>[<span class="ruby-value str">'max'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'min'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'max-ex'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'min-ex'</span>]
|
291
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max</span>
|
292
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">min</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">min</span>
|
293
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_maxltmin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min</span>])
|
294
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">min_ex</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min_ex</span>
|
295
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_maxleminex</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min_ex</span>])
|
296
|
-
<span class="ruby-keyword kw">end</span>
|
297
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">max_ex</span>
|
298
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">min</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min</span>
|
299
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_maxexlemin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min</span>])
|
300
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">min_ex</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min_ex</span>
|
301
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_maxexleminex</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min_ex</span>])
|
302
|
-
<span class="ruby-keyword kw">end</span>
|
303
|
-
<span class="ruby-keyword kw">end</span>
|
304
|
-
<span class="ruby-keyword kw">end</span>
|
305
|
-
<span class="ruby-comment cmt">#</span>
|
306
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'length'</span>)
|
307
|
-
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'length'</span>]
|
308
|
-
<span class="ruby-identifier">curr_path</span> = <span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"/length"</span>
|
309
|
-
<span class="ruby-comment cmt">#val.is_a?(Hash) or errors << validate_error(:length_notmap, rule, curr_path, val)</span>
|
310
|
-
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'str'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'text'</span>
|
311
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_nottext</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'length:'</span>)
|
312
|
-
<span class="ruby-keyword kw">end</span>
|
313
|
-
<span class="ruby-comment cmt">#val.each do |lkey, lval|</span>
|
314
|
-
<span class="ruby-comment cmt"># #case lkey</span>
|
315
|
-
<span class="ruby-comment cmt"># #when 'max', 'min', 'max-ex', 'min-ex'</span>
|
316
|
-
<span class="ruby-comment cmt"># unless lval.is_a?(Integer)</span>
|
317
|
-
<span class="ruby-comment cmt"># errors << validate_error(:length_notint, rule, "#{curr_path}/#{lkey}", lval)</span>
|
318
|
-
<span class="ruby-comment cmt"># end</span>
|
319
|
-
<span class="ruby-comment cmt"># #else</span>
|
320
|
-
<span class="ruby-comment cmt"># # errors << validate_error(:length_undefined, rule, curr_path, "#{lkey}:")</span>
|
321
|
-
<span class="ruby-comment cmt"># #end</span>
|
210
|
+
<span class="ruby-comment cmt"># File kwalify/meta-validator.rb, line 44</span>
|
211
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validate_hook</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">errors</span>)
|
212
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-comment cmt">## realy?</span>
|
213
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">rule</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"MAIN"</span>
|
214
|
+
<span class="ruby-comment cmt">#</span>
|
215
|
+
<span class="ruby-identifier">hash</span> = <span class="ruby-identifier">value</span>
|
216
|
+
<span class="ruby-identifier">type</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'type'</span>]
|
217
|
+
<span class="ruby-identifier">type</span> = <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">DEFAULT_TYPE</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">type</span>.<span class="ruby-identifier">nil?</span>
|
218
|
+
<span class="ruby-identifier">klass</span> = <span class="ruby-constant">Types</span>.<span class="ruby-identifier">type_class</span>(<span class="ruby-identifier">type</span>)
|
219
|
+
<span class="ruby-comment cmt">#unless klass</span>
|
220
|
+
<span class="ruby-comment cmt"># errors << validate_error(:type_unknown, rule, "#{path}/type", type)</span>
|
221
|
+
<span class="ruby-comment cmt">#end</span>
|
222
|
+
<span class="ruby-comment cmt">#</span>
|
223
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'class'</span>)
|
224
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'class'</span>]
|
225
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'map'</span>
|
226
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:class_notmap</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/class"</span>, <span class="ruby-value str">'class:'</span>)
|
227
|
+
<span class="ruby-keyword kw">end</span>
|
228
|
+
<span class="ruby-keyword kw">end</span>
|
229
|
+
<span class="ruby-comment cmt">#</span>
|
230
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'pattern'</span>)
|
231
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'pattern'</span>]
|
232
|
+
<span class="ruby-identifier">pat</span> = (<span class="ruby-identifier">val</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\A\/(.*)\/([mi]?[mi]?)\z/</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">$1</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">val</span>)
|
233
|
+
<span class="ruby-keyword kw">begin</span>
|
234
|
+
<span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">compile</span>(<span class="ruby-identifier">pat</span>)
|
235
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">RegexpError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
236
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:pattern_syntaxerr</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/pattern"</span>, <span class="ruby-identifier">val</span>)
|
237
|
+
<span class="ruby-keyword kw">end</span>
|
238
|
+
<span class="ruby-keyword kw">end</span>
|
239
|
+
<span class="ruby-comment cmt">#</span>
|
240
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'enum'</span>)
|
241
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">Types</span>.<span class="ruby-identifier">collection_type?</span>(<span class="ruby-identifier">type</span>)
|
242
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:enum_notscalar</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'enum:'</span>)
|
243
|
+
<span class="ruby-keyword kw">else</span>
|
244
|
+
<span class="ruby-comment cmt">#elem_table = {}</span>
|
245
|
+
<span class="ruby-identifier">hash</span>[<span class="ruby-value str">'enum'</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">elem</span><span class="ruby-operator">|</span>
|
246
|
+
<span class="ruby-comment cmt">#if elem_table[elem]</span>
|
247
|
+
<span class="ruby-comment cmt"># errors << validate_error(:enum_duplicate, rule, "#{path}/enum", elem.to_s)</span>
|
322
248
|
<span class="ruby-comment cmt">#end</span>
|
323
|
-
<span class="ruby-
|
324
|
-
|
325
|
-
|
326
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'min'</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'min-ex'</span>)
|
327
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_twomin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>)
|
328
|
-
<span class="ruby-keyword kw">end</span>
|
329
|
-
<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min_ex</span> = <span class="ruby-identifier">val</span>[<span class="ruby-value str">'max'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'min'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'max-ex'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'min-ex'</span>]
|
330
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max</span>
|
331
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">min</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">min</span>
|
332
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_maxltmin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min</span>])
|
333
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">min_ex</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min_ex</span>
|
334
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_maxleminex</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min_ex</span>])
|
335
|
-
<span class="ruby-keyword kw">end</span>
|
336
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">max_ex</span>
|
337
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">min</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min</span>
|
338
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_maxexlemin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min</span>])
|
339
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">min_ex</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min_ex</span>
|
340
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_maxexleminex</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min_ex</span>])
|
341
|
-
<span class="ruby-keyword kw">end</span>
|
342
|
-
<span class="ruby-keyword kw">end</span>
|
343
|
-
<span class="ruby-keyword kw">end</span>
|
344
|
-
<span class="ruby-comment cmt">#</span>
|
345
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'unique'</span>)
|
346
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'unique'</span>] <span class="ruby-operator">&&</span> <span class="ruby-constant">Types</span>.<span class="ruby-identifier">collection_type?</span>(<span class="ruby-identifier">type</span>)
|
347
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:unique_notscalar</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">"unique:"</span>)
|
348
|
-
<span class="ruby-keyword kw">end</span>
|
349
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">empty?</span>
|
350
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:unique_onroot</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-value str">"/"</span>, <span class="ruby-value str">"unique:"</span>)
|
351
|
-
<span class="ruby-keyword kw">end</span>
|
352
|
-
<span class="ruby-keyword kw">end</span>
|
353
|
-
<span class="ruby-comment cmt">#</span>
|
354
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'ident'</span>)
|
355
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'ident'</span>] <span class="ruby-operator">&&</span> <span class="ruby-constant">Types</span>.<span class="ruby-identifier">collection_type?</span>(<span class="ruby-identifier">type</span>)
|
356
|
-
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:ident_notscalar</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">"ident:"</span>)
|
249
|
+
<span class="ruby-comment cmt">#elem_table[elem] = true</span>
|
250
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">elem</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-identifier">klass</span>)
|
251
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:enum_type_unmatch</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/enum"</span>, <span class="ruby-identifier">elem</span>, [<span class="ruby-constant">Kwalify</span>.<span class="ruby-identifier">word</span>(<span class="ruby-identifier">type</span>)])
|
357
252
|
<span class="ruby-keyword kw">end</span>
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
<span class="ruby-
|
383
|
-
<span class="ruby-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
<span class="ruby-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
253
|
+
<span class="ruby-keyword kw">end</span>
|
254
|
+
<span class="ruby-keyword kw">end</span>
|
255
|
+
<span class="ruby-keyword kw">end</span>
|
256
|
+
<span class="ruby-comment cmt">#</span>
|
257
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'assert'</span>)
|
258
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'assert'</span>]
|
259
|
+
<span class="ruby-comment cmt">#val =~ /\bval\b/ or errors << validate_error(:assert_noval, rule, "#{path}/assert", val)</span>
|
260
|
+
<span class="ruby-keyword kw">begin</span>
|
261
|
+
<span class="ruby-identifier">eval</span> <span class="ruby-node">"proc { |val| #{val} }"</span>
|
262
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-operator">::</span><span class="ruby-constant">SyntaxError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
263
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:assert_syntaxerr</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/assert"</span>, <span class="ruby-identifier">val</span>)
|
264
|
+
<span class="ruby-keyword kw">end</span>
|
265
|
+
<span class="ruby-keyword kw">end</span>
|
266
|
+
<span class="ruby-comment cmt">#</span>
|
267
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'range'</span>)
|
268
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'range'</span>]
|
269
|
+
<span class="ruby-identifier">curr_path</span> = <span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"/range"</span>
|
270
|
+
<span class="ruby-comment cmt">#if ! val.is_a?(Hash)</span>
|
271
|
+
<span class="ruby-comment cmt"># errors << validate_error(:range_notmap, rule, curr_path, val)</span>
|
272
|
+
<span class="ruby-comment cmt">#elsif ...</span>
|
273
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">Types</span>.<span class="ruby-identifier">collection_type?</span>(<span class="ruby-identifier">type</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'bool'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'any'</span>
|
274
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_notscalar</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'range:'</span>)
|
275
|
+
<span class="ruby-keyword kw">else</span>
|
276
|
+
<span class="ruby-identifier">val</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">rkey</span>, <span class="ruby-identifier">rval</span><span class="ruby-operator">|</span>
|
277
|
+
<span class="ruby-comment cmt">#case rkey</span>
|
278
|
+
<span class="ruby-comment cmt">#when 'max', 'min', 'max-ex', 'min-ex'</span>
|
279
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">rval</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-identifier">klass</span>)
|
280
|
+
<span class="ruby-identifier">typename</span> = <span class="ruby-constant">Kwalify</span>.<span class="ruby-identifier">word</span>(<span class="ruby-identifier">type</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span>
|
281
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_type_unmatch</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{curr_path}/#{rkey}"</span>, <span class="ruby-identifier">rval</span>, [<span class="ruby-identifier">typename</span>])
|
282
|
+
<span class="ruby-keyword kw">end</span>
|
283
|
+
<span class="ruby-comment cmt">#else</span>
|
284
|
+
<span class="ruby-comment cmt"># errors << validate_error(:range_undefined, rule, curr_path, "#{rkey}:")</span>
|
285
|
+
<span class="ruby-comment cmt">#end</span>
|
286
|
+
<span class="ruby-keyword kw">end</span>
|
287
|
+
<span class="ruby-keyword kw">end</span>
|
288
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'max'</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'max-ex'</span>)
|
289
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_twomax</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>)
|
290
|
+
<span class="ruby-keyword kw">end</span>
|
291
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'min'</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'min-ex'</span>)
|
292
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_twomin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>)
|
293
|
+
<span class="ruby-keyword kw">end</span>
|
294
|
+
<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min_ex</span> = <span class="ruby-identifier">val</span>[<span class="ruby-value str">'max'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'min'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'max-ex'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'min-ex'</span>]
|
295
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max</span>
|
296
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">min</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">min</span>
|
297
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_maxltmin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min</span>])
|
298
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">min_ex</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min_ex</span>
|
299
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_maxleminex</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min_ex</span>])
|
300
|
+
<span class="ruby-keyword kw">end</span>
|
301
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">max_ex</span>
|
302
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">min</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min</span>
|
303
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_maxexlemin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min</span>])
|
304
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">min_ex</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min_ex</span>
|
305
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_maxexleminex</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min_ex</span>])
|
306
|
+
<span class="ruby-keyword kw">end</span>
|
307
|
+
<span class="ruby-keyword kw">end</span>
|
414
308
|
<span class="ruby-keyword kw">end</span>
|
309
|
+
<span class="ruby-comment cmt">#</span>
|
310
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'length'</span>)
|
311
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'length'</span>]
|
312
|
+
<span class="ruby-identifier">curr_path</span> = <span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"/length"</span>
|
313
|
+
<span class="ruby-comment cmt">#val.is_a?(Hash) or errors << validate_error(:length_notmap, rule, curr_path, val)</span>
|
314
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'str'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'text'</span>
|
315
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_nottext</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'length:'</span>)
|
316
|
+
<span class="ruby-keyword kw">end</span>
|
317
|
+
<span class="ruby-comment cmt">#val.each do |lkey, lval|</span>
|
318
|
+
<span class="ruby-comment cmt"># #case lkey</span>
|
319
|
+
<span class="ruby-comment cmt"># #when 'max', 'min', 'max-ex', 'min-ex'</span>
|
320
|
+
<span class="ruby-comment cmt"># unless lval.is_a?(Integer)</span>
|
321
|
+
<span class="ruby-comment cmt"># errors << validate_error(:length_notint, rule, "#{curr_path}/#{lkey}", lval)</span>
|
322
|
+
<span class="ruby-comment cmt"># end</span>
|
323
|
+
<span class="ruby-comment cmt"># #else</span>
|
324
|
+
<span class="ruby-comment cmt"># # errors << validate_error(:length_undefined, rule, curr_path, "#{lkey}:")</span>
|
325
|
+
<span class="ruby-comment cmt"># #end</span>
|
326
|
+
<span class="ruby-comment cmt">#end</span>
|
327
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'max'</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'max-ex'</span>)
|
328
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_twomax</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>)
|
329
|
+
<span class="ruby-keyword kw">end</span>
|
330
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'min'</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'min-ex'</span>)
|
331
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_twomin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>)
|
332
|
+
<span class="ruby-keyword kw">end</span>
|
333
|
+
<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min_ex</span> = <span class="ruby-identifier">val</span>[<span class="ruby-value str">'max'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'min'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'max-ex'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'min-ex'</span>]
|
334
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max</span>
|
335
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">min</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">min</span>
|
336
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_maxltmin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min</span>])
|
337
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">min_ex</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min_ex</span>
|
338
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_maxleminex</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min_ex</span>])
|
339
|
+
<span class="ruby-keyword kw">end</span>
|
340
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">max_ex</span>
|
341
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">min</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min</span>
|
342
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_maxexlemin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min</span>])
|
343
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">min_ex</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min_ex</span>
|
344
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_maxexleminex</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min_ex</span>])
|
345
|
+
<span class="ruby-keyword kw">end</span>
|
346
|
+
<span class="ruby-keyword kw">end</span>
|
347
|
+
<span class="ruby-keyword kw">end</span>
|
348
|
+
<span class="ruby-comment cmt">#</span>
|
349
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'unique'</span>)
|
350
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'unique'</span>] <span class="ruby-operator">&&</span> <span class="ruby-constant">Types</span>.<span class="ruby-identifier">collection_type?</span>(<span class="ruby-identifier">type</span>)
|
351
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:unique_notscalar</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">"unique:"</span>)
|
352
|
+
<span class="ruby-keyword kw">end</span>
|
353
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">empty?</span>
|
354
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:unique_onroot</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-value str">"/"</span>, <span class="ruby-value str">"unique:"</span>)
|
355
|
+
<span class="ruby-keyword kw">end</span>
|
356
|
+
<span class="ruby-keyword kw">end</span>
|
357
|
+
<span class="ruby-comment cmt">#</span>
|
358
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'ident'</span>)
|
359
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'ident'</span>] <span class="ruby-operator">&&</span> <span class="ruby-constant">Types</span>.<span class="ruby-identifier">collection_type?</span>(<span class="ruby-identifier">type</span>)
|
360
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:ident_notscalar</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">"ident:"</span>)
|
361
|
+
<span class="ruby-keyword kw">end</span>
|
362
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">empty?</span>
|
363
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:ident_onroot</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-value str">"/"</span>, <span class="ruby-value str">"ident:"</span>)
|
364
|
+
<span class="ruby-keyword kw">end</span>
|
365
|
+
<span class="ruby-keyword kw">end</span>
|
366
|
+
<span class="ruby-comment cmt">#</span>
|
367
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'default'</span>)
|
368
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'default'</span>]
|
369
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">Types</span>.<span class="ruby-identifier">collection_type?</span>(<span class="ruby-identifier">type</span>)
|
370
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:default_notscalar</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">"default:"</span>)
|
371
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-operator">!</span><span class="ruby-identifier">val</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">val</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-identifier">klass</span>)
|
372
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:default_unmatch</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/default"</span>, <span class="ruby-identifier">val</span>, [<span class="ruby-constant">Kwalify</span>.<span class="ruby-identifier">word</span>(<span class="ruby-identifier">type</span>)])
|
373
|
+
<span class="ruby-keyword kw">end</span>
|
374
|
+
<span class="ruby-keyword kw">end</span>
|
375
|
+
<span class="ruby-comment cmt">#</span>
|
376
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'sequence'</span>)
|
377
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'sequence'</span>]
|
378
|
+
<span class="ruby-comment cmt">#if !val.nil? && !val.is_a?(Array)</span>
|
379
|
+
<span class="ruby-comment cmt"># errors << validate_error(:sequence_notseq, rule, "#{path}/sequence", val)</span>
|
380
|
+
<span class="ruby-comment cmt">#elsif ...</span>
|
381
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">empty?</span>
|
382
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:sequence_noelem</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/sequence"</span>, <span class="ruby-identifier">val</span>)
|
383
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span>
|
384
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:sequence_toomany</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/sequence"</span>, <span class="ruby-identifier">val</span>)
|
385
|
+
<span class="ruby-keyword kw">else</span>
|
386
|
+
<span class="ruby-identifier">elem</span> = <span class="ruby-identifier">val</span>[<span class="ruby-value">0</span>]
|
387
|
+
<span class="ruby-identifier">assert_error</span>(<span class="ruby-node">"elem.class=#{elem.class}"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">elem</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
388
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">elem</span>[<span class="ruby-value str">'ident'</span>] <span class="ruby-operator">&&</span> <span class="ruby-identifier">elem</span>[<span class="ruby-value str">'type'</span>] <span class="ruby-operator">!=</span> <span class="ruby-value str">'map'</span>
|
389
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:ident_notmap</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-node">"#{path}/sequence/0"</span>, <span class="ruby-value str">'ident:'</span>)
|
390
|
+
<span class="ruby-keyword kw">end</span>
|
391
|
+
<span class="ruby-keyword kw">end</span>
|
392
|
+
<span class="ruby-keyword kw">end</span>
|
393
|
+
<span class="ruby-comment cmt">#</span>
|
394
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'mapping'</span>)
|
395
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'mapping'</span>]
|
396
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">val</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">val</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
397
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:mapping_notmap</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/mapping"</span>, <span class="ruby-identifier">val</span>)
|
398
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">val</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">val</span>.<span class="ruby-identifier">default</span>)
|
399
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:mapping_noelem</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/mapping"</span>, <span class="ruby-identifier">val</span>)
|
400
|
+
<span class="ruby-keyword kw">end</span>
|
401
|
+
<span class="ruby-keyword kw">end</span>
|
402
|
+
<span class="ruby-comment cmt">#</span>
|
403
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'seq'</span>
|
404
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:seq_nosequence</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-keyword kw">nil</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'sequence'</span>)
|
405
|
+
<span class="ruby-comment cmt">#errors << validate_error(:seq_conflict, rule, path, 'enum:') if hash.key?('enum')</span>
|
406
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:seq_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'pattern:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'pattern'</span>)
|
407
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:seq_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'mapping:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'mapping'</span>)
|
408
|
+
<span class="ruby-comment cmt">#errors << validate_error(:seq_conflict, rule, path, 'range:') if hash.key?('range')</span>
|
409
|
+
<span class="ruby-comment cmt">#errors << validate_error(:seq_conflict, rule, path, 'length:') if hash.key?('length')</span>
|
410
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'map'</span>
|
411
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:map_nomapping</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-keyword kw">nil</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'mapping'</span>)
|
412
|
+
<span class="ruby-comment cmt">#errors << validate_error(:map_conflict, rule, path, 'enum:') if hash.key?('enum')</span>
|
413
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:map_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'pattern:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'pattern'</span>)
|
414
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:map_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'sequence:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'sequence'</span>)
|
415
|
+
<span class="ruby-comment cmt">#errors << validate_error(:map_conflict, rule, path, 'range:') if hash.key?('range')</span>
|
416
|
+
<span class="ruby-comment cmt">#errors << validate_error(:map_conflict, rule, path, 'length:') if hash.key?('length')</span>
|
417
|
+
<span class="ruby-keyword kw">else</span>
|
418
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:scalar_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'sequence:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'sequence'</span>)
|
419
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:scalar_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'mapping:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'mapping'</span>)
|
420
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'enum'</span>)
|
421
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:enum_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'range:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'range'</span>)
|
422
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:enum_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'length:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'length'</span>)
|
423
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:enum_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'pattern:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'pattern'</span>)
|
424
|
+
<span class="ruby-keyword kw">end</span>
|
425
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'default'</span>)
|
426
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:default_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'default:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'required'</span>]
|
427
|
+
<span class="ruby-keyword kw">end</span>
|
428
|
+
<span class="ruby-keyword kw">end</span>
|
429
|
+
|
430
|
+
<span class="ruby-keyword kw">end</span>
|
415
431
|
</pre>
|
416
432
|
</div>
|
417
433
|
</div>
|