kwalify 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. data/CHANGES.txt +232 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.txt +16 -19
  4. data/bin/kwalify +3 -3
  5. data/contrib/inline-require +6 -4
  6. data/contrib/kwalify +3719 -2427
  7. data/doc-api/classes/CommandOptionError.html +17 -17
  8. data/doc-api/classes/CommandOptionParser.html +63 -63
  9. data/doc-api/classes/Kwalify.html +29 -7
  10. data/doc-api/classes/Kwalify/AssertionError.html +9 -9
  11. data/doc-api/classes/Kwalify/BaseError.html +72 -71
  12. data/doc-api/classes/Kwalify/BaseParser.html +461 -0
  13. data/doc-api/classes/Kwalify/CommandOptionError.html +11 -11
  14. data/doc-api/classes/Kwalify/ErrorHelper.html +51 -46
  15. data/doc-api/classes/Kwalify/HashInterface.html +13 -135
  16. data/doc-api/classes/Kwalify/Json.html +105 -0
  17. data/doc-api/classes/Kwalify/Main.html +129 -126
  18. data/doc-api/classes/Kwalify/MetaValidator.html +248 -232
  19. data/doc-api/classes/Kwalify/Parser.html +12 -12
  20. data/doc-api/classes/Kwalify/PlainYamlParser.html +166 -163
  21. data/doc-api/classes/Kwalify/PlainYamlParser/Alias.html +11 -11
  22. data/doc-api/classes/Kwalify/Rule.html +152 -130
  23. data/doc-api/classes/Kwalify/SchemaError.html +10 -10
  24. data/doc-api/classes/Kwalify/SyntaxError.html +185 -0
  25. data/doc-api/classes/Kwalify/Types.html +26 -25
  26. data/doc-api/classes/Kwalify/Util.html +389 -0
  27. data/doc-api/classes/Kwalify/Util/HashLike.html +246 -0
  28. data/doc-api/classes/Kwalify/Util/OrderedHash.html +330 -0
  29. data/doc-api/classes/Kwalify/ValidationError.html +10 -10
  30. data/doc-api/classes/Kwalify/Validator.html +153 -86
  31. data/doc-api/classes/Kwalify/Yaml.html +181 -0
  32. data/doc-api/classes/Kwalify/Yaml/Parser.html +1538 -0
  33. data/doc-api/classes/Kwalify/YamlParser.html +190 -183
  34. data/doc-api/classes/Kwalify/YamlSyntaxError.html +8 -57
  35. data/doc-api/created.rid +1 -1
  36. data/doc-api/files/__/README_txt.html +17 -22
  37. data/doc-api/files/kwalify/errors_rb.html +2 -2
  38. data/doc-api/files/kwalify/main_rb.html +4 -3
  39. data/doc-api/files/kwalify/messages_rb.html +2 -2
  40. data/doc-api/files/kwalify/meta-validator_rb.html +3 -3
  41. data/doc-api/files/kwalify/{util/yaml-helper_rb.html → parser/base_rb.html} +8 -6
  42. data/doc-api/files/kwalify/parser/yaml_rb.html +117 -0
  43. data/doc-api/files/kwalify/rule_rb.html +2 -2
  44. data/doc-api/files/kwalify/types_rb.html +2 -2
  45. data/doc-api/files/kwalify/util/assert-text-equal_rb.html +2 -2
  46. data/doc-api/files/kwalify/util/hash-interface_rb.html +9 -2
  47. data/doc-api/files/kwalify/util/hashlike_rb.html +107 -0
  48. data/doc-api/files/kwalify/util/option-parser_rb.html +2 -2
  49. data/doc-api/files/kwalify/util/ordered-hash_rb.html +107 -0
  50. data/doc-api/files/kwalify/util/testcase-helper_rb.html +2 -2
  51. data/doc-api/files/kwalify/util_rb.html +107 -0
  52. data/doc-api/files/kwalify/validator_rb.html +2 -2
  53. data/doc-api/files/kwalify/yaml-parser_rb.html +2 -2
  54. data/doc-api/files/kwalify_rb.html +3 -2
  55. data/doc-api/fr_class_index.html +8 -1
  56. data/doc-api/fr_file_index.html +5 -1
  57. data/doc-api/fr_method_index.html +128 -69
  58. data/doc/img/fig01.png +0 -0
  59. data/doc/users-guide.html +882 -717
  60. data/examples/address-book/address-book.schema.yaml +2 -2
  61. data/examples/data-binding/BABEL.data.yaml +63 -0
  62. data/examples/data-binding/BABEL.schema.yaml +31 -0
  63. data/examples/data-binding/Makefile +8 -0
  64. data/examples/data-binding/Rakefile +13 -0
  65. data/examples/data-binding/main.rb +27 -0
  66. data/examples/invoice/invoice.schema.yaml +3 -3
  67. data/examples/tapkit/tapkit.schema.yaml +2 -2
  68. data/lib/kwalify.rb +41 -4
  69. data/lib/kwalify/errors.rb +118 -96
  70. data/lib/kwalify/kwalify.schema.yaml +58 -0
  71. data/lib/kwalify/main.rb +384 -377
  72. data/lib/kwalify/messages.rb +41 -27
  73. data/lib/kwalify/meta-validator.rb +251 -331
  74. data/lib/kwalify/parser/base.rb +127 -0
  75. data/lib/kwalify/parser/yaml.rb +837 -0
  76. data/lib/kwalify/rule.rb +545 -487
  77. data/lib/kwalify/templates/genclass-java.eruby +189 -162
  78. data/lib/kwalify/templates/genclass-php.eruby +104 -0
  79. data/lib/kwalify/templates/genclass-ruby.eruby +95 -66
  80. data/lib/kwalify/types.rb +107 -106
  81. data/lib/kwalify/util.rb +157 -0
  82. data/lib/kwalify/util/assert-text-equal.rb +33 -31
  83. data/lib/kwalify/util/hash-interface.rb +11 -30
  84. data/lib/kwalify/util/hashlike.rb +51 -0
  85. data/lib/kwalify/util/option-parser.rb +144 -144
  86. data/lib/kwalify/util/ordered-hash.rb +57 -0
  87. data/lib/kwalify/util/testcase-helper.rb +3 -3
  88. data/lib/kwalify/validator.rb +267 -212
  89. data/lib/kwalify/yaml-parser.rb +822 -768
  90. data/setup.rb +861 -607
  91. data/test/Rookbook.yaml +10 -0
  92. data/test/{tmp.dir/Context.java → data/users-guide/AddressBook.java.expected} +11 -11
  93. data/test/data/users-guide/BABEL.data.yaml +24 -0
  94. data/test/data/users-guide/BABEL.schema.yaml +30 -0
  95. data/test/data/users-guide/ExampleAddressBook.java +47 -0
  96. data/test/{tmp.dir/Group.java → data/users-guide/Group.java.expected} +2 -11
  97. data/test/data/users-guide/Person.java.expected +44 -0
  98. data/test/data/users-guide/address_book.rb +52 -0
  99. data/test/data/users-guide/address_book.schema.yaml +28 -0
  100. data/test/data/users-guide/address_book.yaml +27 -0
  101. data/test/data/users-guide/answers-schema.yaml +12 -0
  102. data/test/data/users-guide/answers-validator.rb +52 -0
  103. data/test/data/users-guide/babel_genclass.result +26 -0
  104. data/test/data/users-guide/config.schema.yaml +7 -0
  105. data/test/data/users-guide/config.yaml +4 -0
  106. data/test/{tmp.dir/silent1.document → data/users-guide/document01a.yaml} +0 -0
  107. data/test/data/users-guide/document01b.yaml +3 -0
  108. data/test/data/users-guide/document02a.yaml +4 -0
  109. data/test/data/users-guide/document02b.yaml +4 -0
  110. data/test/data/users-guide/document03a.yaml +6 -0
  111. data/test/data/users-guide/document03b.yaml +6 -0
  112. data/test/data/users-guide/document04a.yaml +9 -0
  113. data/test/data/users-guide/document04b.yaml +9 -0
  114. data/test/data/users-guide/document05a.yaml +11 -0
  115. data/test/data/users-guide/document05b.yaml +12 -0
  116. data/test/data/users-guide/document06a.yaml +15 -0
  117. data/test/data/users-guide/document06b.yaml +16 -0
  118. data/test/data/users-guide/document07a.yaml +9 -0
  119. data/test/data/users-guide/document07b.yaml +7 -0
  120. data/test/data/users-guide/document12a.json +10 -0
  121. data/test/data/users-guide/document12b.json +6 -0
  122. data/test/data/users-guide/document13a.yaml +17 -0
  123. data/test/data/users-guide/document14a.yaml +3 -0
  124. data/test/data/users-guide/document14b.yaml +3 -0
  125. data/test/data/users-guide/document15a.yaml +6 -0
  126. data/test/data/users-guide/document15b.yaml +5 -0
  127. data/test/data/users-guide/example_address_book.rb +10 -0
  128. data/test/data/users-guide/example_address_book_java.result +32 -0
  129. data/test/data/users-guide/example_address_book_ruby.result +31 -0
  130. data/test/data/users-guide/genclass_java.result +4 -0
  131. data/test/data/users-guide/howto-validation-with-parsing.rb +28 -0
  132. data/test/data/users-guide/howto-validation.rb +25 -0
  133. data/test/data/users-guide/howto3.rb +6 -0
  134. data/test/data/users-guide/howto3.result +5 -0
  135. data/test/data/users-guide/howto3.yaml +8 -0
  136. data/test/data/users-guide/howto5_databinding.result +111 -0
  137. data/test/data/users-guide/invalid01.result +3 -0
  138. data/test/data/users-guide/invalid02.result +5 -0
  139. data/test/data/users-guide/invalid03.result +5 -0
  140. data/test/data/users-guide/invalid04.result +4 -0
  141. data/test/data/users-guide/invalid05.result +11 -0
  142. data/test/data/users-guide/invalid06.result +4 -0
  143. data/test/data/users-guide/invalid07.result +3 -0
  144. data/test/data/users-guide/invalid08.result +3 -0
  145. data/test/data/users-guide/invalid12.json +8 -0
  146. data/test/data/users-guide/invalid14.result +4 -0
  147. data/test/data/users-guide/invalid15.result +4 -0
  148. data/test/data/users-guide/loadbabel.rb +27 -0
  149. data/test/data/users-guide/loadconfig.rb +15 -0
  150. data/test/data/users-guide/loadconfig.result +2 -0
  151. data/test/data/users-guide/models.rb +22 -0
  152. data/test/data/users-guide/option_ha.result +6 -0
  153. data/test/data/users-guide/option_ha_genclass_java.result +7 -0
  154. data/test/{tmp.dir/meta1.schema → data/users-guide/schema01.yaml} +0 -0
  155. data/test/data/users-guide/schema02.yaml +12 -0
  156. data/test/data/users-guide/schema03.yaml +9 -0
  157. data/test/data/users-guide/schema04.yaml +20 -0
  158. data/test/data/users-guide/schema05.yaml +29 -0
  159. data/test/data/users-guide/schema06.yaml +11 -0
  160. data/test/data/users-guide/schema12.json +12 -0
  161. data/test/data/users-guide/schema13.yaml +13 -0
  162. data/test/data/users-guide/schema14.yaml +5 -0
  163. data/test/data/users-guide/schema15.yaml +21 -0
  164. data/test/data/users-guide/valid01.result +2 -0
  165. data/test/data/users-guide/valid02.result +2 -0
  166. data/test/data/users-guide/valid03.result +2 -0
  167. data/test/data/users-guide/valid04.result +2 -0
  168. data/test/data/users-guide/valid05.result +2 -0
  169. data/test/data/users-guide/valid06.result +2 -0
  170. data/test/data/users-guide/valid07.result +2 -0
  171. data/test/data/users-guide/valid08.result +2 -0
  172. data/test/data/users-guide/valid12.result +2 -0
  173. data/test/data/users-guide/valid13.result +2 -0
  174. data/test/data/users-guide/valid14.result +2 -0
  175. data/test/data/users-guide/valid15.result +2 -0
  176. data/test/data/users-guide/validate08.rb +37 -0
  177. data/test/test-action.rb +78 -0
  178. data/test/test-action.yaml +738 -0
  179. data/test/test-databinding.rb +80 -0
  180. data/test/test-databinding.yaml +301 -0
  181. data/test/test-main.rb +129 -150
  182. data/test/test-main.yaml +126 -321
  183. data/test/test-metavalidator.rb +47 -47
  184. data/test/test-metavalidator.yaml +77 -21
  185. data/test/test-parser-yaml.rb +57 -0
  186. data/test/test-parser-yaml.yaml +1749 -0
  187. data/test/test-rule.rb +14 -15
  188. data/test/test-rule.yaml +6 -3
  189. data/test/test-users-guide.rb +75 -0
  190. data/test/test-validator.rb +77 -52
  191. data/test/test-validator.yaml +168 -6
  192. data/test/test-yaml-parser.rb +47 -0
  193. data/test/{test-yamlparser.yaml → test-yaml-parser.yaml} +159 -52
  194. data/test/test.rb +37 -21
  195. metadata +136 -37
  196. data/COPYING +0 -340
  197. data/ChangeLog +0 -70
  198. data/doc-api/classes/YamlHelper.html +0 -259
  199. data/lib/kwalify/util/yaml-helper.rb +0 -82
  200. data/test/test-yamlparser.rb +0 -58
  201. data/test/tmp.dir/User.java +0 -43
  202. data/test/tmp.dir/action1.document +0 -18
  203. data/test/tmp.dir/action1.schema +0 -32
  204. data/test/tmp.dir/action2.document +0 -18
  205. data/test/tmp.dir/action2.schema +0 -32
  206. data/test/tmp.dir/emacs.document +0 -6
  207. data/test/tmp.dir/emacs.schema +0 -6
  208. data/test/tmp.dir/meta1.document +0 -0
  209. data/test/tmp.dir/meta2.document +0 -0
  210. data/test/tmp.dir/meta2.schema +0 -3
  211. data/test/tmp.dir/silent1.schema +0 -3
  212. data/test/tmp.dir/silent2.document +0 -7
  213. data/test/tmp.dir/silent2.schema +0 -3
  214. data/test/tmp.dir/stream.invalid +0 -8
  215. data/test/tmp.dir/stream.schema +0 -3
  216. data/test/tmp.dir/stream.valid +0 -8
  217. data/test/tmp.dir/untabify.document +0 -5
  218. data/test/tmp.dir/untabify.schema +0 -10
  219. data/todo.txt +0 -34
@@ -83,18 +83,18 @@
83
83
  ex.
84
84
  </p>
85
85
  <pre>
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 =&gt; ex
92
- $stderr.puts &quot;ERROR: #{ex.message}&quot;
93
- exit 1
94
- rescue Kwalify::KwalifyError =&gt; ex
95
- $stderr.puts &quot;ERROR: #{ex.message}&quot;
96
- exit 1
97
- end
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 =&gt; ex
92
+ $stderr.puts &quot;ERROR: #{ex.message}&quot;
93
+ exit 1
94
+ rescue Kwalify::KwalifyError =&gt; ex
95
+ $stderr.puts &quot;ERROR: #{ex.message}&quot;
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="#M000039">_inspect</a>&nbsp;&nbsp;
110
- <a href="#M000038">debug?</a>&nbsp;&nbsp;
111
- <a href="#M000040">execute</a>&nbsp;&nbsp;
112
- <a href="#M000041">main</a>&nbsp;&nbsp;
113
- <a href="#M000037">new</a>&nbsp;&nbsp;
109
+ <a href="#M000088">_inspect</a>&nbsp;&nbsp;
110
+ <a href="#M000087">debug?</a>&nbsp;&nbsp;
111
+ <a href="#M000089">execute</a>&nbsp;&nbsp;
112
+ <a href="#M000090">main</a>&nbsp;&nbsp;
113
+ <a href="#M000086">new</a>&nbsp;&nbsp;
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-M000041" class="method-detail">
136
- <a name="M000041"></a>
135
+ <div id="method-M000090" class="method-detail">
136
+ <a name="M000090"></a>
137
137
 
138
138
  <div class="method-heading">
139
- <a href="#M000041" class="method-signature">
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('M000041-source');return false;">[Source]</a></p>
147
- <div class="method-source-code" id="M000041-source">
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 120</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">&gt;</span> <span class="ruby-identifier">ex</span>
156
- <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">ex</span>.<span class="ruby-identifier">message</span>
157
- <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
158
- <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">&gt;</span> <span class="ruby-identifier">ex</span>
159
- <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;ERROR: #{ex.message}&quot;</span>
160
- <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
161
- <span class="ruby-comment cmt">#rescue =&gt; ex</span>
162
- <span class="ruby-comment cmt"># if main.debug?</span>
163
- <span class="ruby-comment cmt"># raise ex</span>
164
- <span class="ruby-comment cmt"># else</span>
165
- <span class="ruby-comment cmt"># $stderr.puts ex.message</span>
166
- <span class="ruby-comment cmt"># exit 1</span>
167
- <span class="ruby-comment cmt"># end</span>
168
- <span class="ruby-keyword kw">end</span>
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">&gt;</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">&gt;</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">&quot;ERROR: #{ex.to_s}&quot;</span>
162
+ <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
163
+ <span class="ruby-comment cmt">#rescue =&gt; 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-M000037" class="method-detail">
176
- <a name="M000037"></a>
177
+ <div id="method-M000086" class="method-detail">
178
+ <a name="M000086"></a>
177
179
 
178
180
  <div class="method-heading">
179
- <a href="#M000037" class="method-signature">
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('M000037-source');return false;">[Source]</a></p>
187
- <div class="method-source-code" id="M000037-source">
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
- <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>)
191
- <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>)
192
- <span class="ruby-ivar">@options</span> = {}
193
- <span class="ruby-ivar">@properties</span> = {}
194
- <span class="ruby-ivar">@template_path</span> = []
195
- <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>
196
- <span class="ruby-identifier">tpath</span> = <span class="ruby-node">&quot;#{path}/kwalify/templates&quot;</span>
197
- <span class="ruby-ivar">@template_path</span> <span class="ruby-operator">&lt;&lt;</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>)
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">&quot;#{path}/kwalify/templates&quot;</span>
199
+ <span class="ruby-ivar">@template_path</span> <span class="ruby-operator">&lt;&lt;</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-M000039" class="method-detail">
208
- <a name="M000039"></a>
209
+ <div id="method-M000088" class="method-detail">
210
+ <a name="M000088"></a>
209
211
 
210
212
  <div class="method-heading">
211
- <a href="#M000039" class="method-signature">
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('M000039-source');return false;">[Source]</a></p>
219
- <div class="method-source-code" id="M000039-source">
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
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_inspect</span>()
223
- <span class="ruby-identifier">sb</span> = []
224
- <span class="ruby-identifier">sb</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;command: #{@command}\n&quot;</span>
225
- <span class="ruby-identifier">sb</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;options:\n&quot;</span>
226
- <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">&lt;=&gt;</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>
227
- <span class="ruby-identifier">sb</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; - #{key}: #{@options[key]}\n&quot;</span>
228
- <span class="ruby-keyword kw">end</span>
229
- <span class="ruby-identifier">sb</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;properties:\n&quot;</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">&lt;&lt;</span> <span class="ruby-node">&quot; - #{key}: #{@properties[key]}\n&quot;</span>
232
- <span class="ruby-keyword kw">end</span>
233
- <span class="ruby-comment cmt">#sb &lt;&lt; &quot;template_path:\n&quot;</span>
234
- <span class="ruby-comment cmt">#@template_path.each do |path|</span>
235
- <span class="ruby-comment cmt"># sb &lt;&lt; &quot; - #{path}\n&quot;</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">&lt;&lt;</span> <span class="ruby-node">&quot;command: #{@command}\n&quot;</span>
227
+ <span class="ruby-identifier">sb</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;options:\n&quot;</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">&lt;=&gt;</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">&lt;&lt;</span> <span class="ruby-node">&quot; - #{key}: #{@options[key]}\n&quot;</span>
238
230
  <span class="ruby-keyword kw">end</span>
231
+ <span class="ruby-identifier">sb</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;properties:\n&quot;</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">&lt;&lt;</span> <span class="ruby-node">&quot; - #{key}: #{@properties[key]}\n&quot;</span>
234
+ <span class="ruby-keyword kw">end</span>
235
+ <span class="ruby-comment cmt">#sb &lt;&lt; &quot;template_path:\n&quot;</span>
236
+ <span class="ruby-comment cmt">#@template_path.each do |path|</span>
237
+ <span class="ruby-comment cmt"># sb &lt;&lt; &quot; - #{path}\n&quot;</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-M000038" class="method-detail">
245
- <a name="M000038"></a>
246
+ <div id="method-M000087" class="method-detail">
247
+ <a name="M000087"></a>
246
248
 
247
249
  <div class="method-heading">
248
- <a href="#M000038" class="method-signature">
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('M000038-source');return false;">[Source]</a></p>
256
- <div class="method-source-code" id="M000038-source">
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
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug?</span>
260
- <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:debug</span>]
261
- <span class="ruby-keyword kw">end</span>
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-M000040" class="method-detail">
268
- <a name="M000040"></a>
269
+ <div id="method-M000089" class="method-detail">
270
+ <a name="M000089"></a>
269
271
 
270
272
  <div class="method-heading">
271
- <a href="#M000040" class="method-signature">
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('M000040-source');return false;">[Source]</a></p>
279
- <div class="method-source-code" id="M000040-source">
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
- <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>)
283
- <span class="ruby-comment cmt"># parse command-line options</span>
284
- <span class="ruby-identifier">filenames</span> = <span class="ruby-identifier">_parse_argv</span>(<span class="ruby-identifier">argv</span>)
285
-
286
- <span class="ruby-comment cmt"># help or version</span>
287
- <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>]
288
- <span class="ruby-identifier">action</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:action</span>]
289
- <span class="ruby-identifier">s</span> = <span class="ruby-value str">''</span>
290
- <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">_version</span>() <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;\n&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:version</span>]
291
- <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">action</span>
292
- <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">action</span>
293
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
294
- <span class="ruby-keyword kw">end</span>
295
-
296
- <span class="ruby-comment cmt"># validation</span>
297
- <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:meta2</span>]
298
- <span class="ruby-identifier">s</span> = <span class="ruby-identifier">_quick_meta_validate</span>(<span class="ruby-identifier">filenames</span>)
299
- <span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:meta</span>]
300
- <span class="ruby-identifier">s</span> = <span class="ruby-identifier">_meta_validate</span>(<span class="ruby-identifier">filenames</span>)
301
- <span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:action</span>]
302
- <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:schema</span>]
303
- <span class="ruby-comment cmt">#* key=:command_option_actionnoschema msg=&quot;schema filename is not specified.&quot;</span>
304
- <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>])
305
- <span class="ruby-keyword kw">end</span>
306
- <span class="ruby-identifier">s</span> = <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>])
307
- <span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:schema</span>]
308
- <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:debug</span>]
309
- <span class="ruby-identifier">s</span> = <span class="ruby-identifier">_inspect_schema</span>(<span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:schema</span>])
310
- <span class="ruby-keyword kw">else</span>
311
- <span class="ruby-identifier">s</span> = <span class="ruby-identifier">_validate</span>(<span class="ruby-identifier">filenames</span>, <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:schema</span>])
312
- <span class="ruby-keyword kw">end</span>
313
- <span class="ruby-keyword kw">else</span>
314
- <span class="ruby-comment cmt">#* key=:command_option_noaction msg=&quot;command-line option '-f' or '-m' required.&quot;</span>
315
- <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>)
316
- <span class="ruby-keyword kw">end</span>
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">&lt;&lt;</span> <span class="ruby-identifier">_version</span>() <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;\n&quot;</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">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">action</span>
294
+ <span class="ruby-identifier">s</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</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=&quot;schema filename is not specified.&quot;</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=&quot;command-line option '-f' or '-m' required.&quot;</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="#M000061">instance</a>&nbsp;&nbsp;
108
- <a href="#M000059">new</a>&nbsp;&nbsp;
109
- <a href="#M000060">validate_hook</a>&nbsp;&nbsp;
107
+ <a href="#M000121">instance</a>&nbsp;&nbsp;
108
+ <a href="#M000122">new</a>&nbsp;&nbsp;
109
+ <a href="#M000123">validate_hook</a>&nbsp;&nbsp;
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">&lt;&lt;'END' name: MAIN type: map required: yes mapping: &amp;main-rule &quot;name&quot;: type: str &quot;desc&quot;: type: str &quot;classname&quot;: type: str &quot;type&quot;: type: str #required: yes enum: - seq #- sequence #- list - map #- mapping #- hash - str #- string - int #- integer - float - number #- numeric - bool #- boolean - text - date - time - timestamp #- object - any - scalar #- collection &quot;required&quot;: type: bool &quot;enum&quot;: type: seq sequence: - type: scalar unique: yes &quot;pattern&quot;: type: str &quot;assert&quot;: type: str pattern: /\bval\b/ &quot;range&quot;: type: map mapping: &quot;max&quot;: type: scalar &quot;min&quot;: type: scalar &quot;max-ex&quot;: type: scalar &quot;min-ex&quot;: type: scalar &quot;length&quot;: type: map mapping: &quot;max&quot;: type: int &quot;min&quot;: type: int &quot;max-ex&quot;: type: int &quot;min-ex&quot;: type: int &quot;ident&quot;: type: bool &quot;unique&quot;: type: bool &quot;sequence&quot;: name: SEQUENCE type: seq sequence: - type: map mapping: *main-rule name: MAIN #required: yes &quot;mapping&quot;: name: MAPPING type: map mapping: =: type: map mapping: *main-rule name: MAIN #required: yes END</td>
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-M000061" class="method-detail">
145
- <a name="M000061"></a>
144
+ <div id="method-M000121" class="method-detail">
145
+ <a name="M000121"></a>
146
146
 
147
147
  <div class="method-heading">
148
- <a href="#M000061" class="method-signature">
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('M000061-source');return false;">[Source]</a></p>
156
- <div class="method-source-code" id="M000061-source">
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 342</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">return</span> <span class="ruby-ivar">@instance</span>
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-M000059" class="method-detail">
168
- <a name="M000059"></a>
171
+ <div id="method-M000122" class="method-detail">
172
+ <a name="M000122"></a>
169
173
 
170
174
  <div class="method-heading">
171
- <a href="#M000059" class="method-signature">
175
+ <a href="#M000122" class="method-signature">
172
176
  <span class="method-name">new</span><span class="method-args">(schema, &amp;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('M000059-source');return false;">[Source]</a></p>
179
- <div class="method-source-code" id="M000059-source">
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 125</span>
182
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">schema</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
183
- <span class="ruby-keyword kw">super</span>
184
- <span class="ruby-keyword kw">end</span>
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">&amp;</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-M000060" class="method-detail">
193
- <a name="M000060"></a>
196
+ <div id="method-M000123" class="method-detail">
197
+ <a name="M000123"></a>
194
198
 
195
199
  <div class="method-heading">
196
- <a href="#M000060" class="method-signature">
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('M000060-source');return false;">[Source]</a></p>
204
- <div class="method-source-code" id="M000060-source">
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 129</span>
207
- <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>)
208
- <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt">## realy?</span>
209
- <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">&quot;MAIN&quot;</span>
210
- <span class="ruby-comment cmt">#</span>
211
- <span class="ruby-identifier">hash</span> = <span class="ruby-identifier">value</span>
212
- <span class="ruby-identifier">type</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'type'</span>]
213
- <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-operator">==</span> <span class="ruby-keyword kw">nil</span>
214
- <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>)
215
- <span class="ruby-comment cmt">#unless klass</span>
216
- <span class="ruby-comment cmt"># errors &lt;&lt; validate_error(:type_unknown, rule, &quot;#{path}/type&quot;, type)</span>
217
- <span class="ruby-comment cmt">#end</span>
218
- <span class="ruby-comment cmt">#</span>
219
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'classname'</span>)
220
- <span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'classname'</span>]
221
- <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>
222
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:classname_notmap</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">&quot;#{path}/classname&quot;</span>, <span class="ruby-value str">'classname:'</span>)
223
- <span class="ruby-keyword kw">end</span>
224
- <span class="ruby-keyword kw">end</span>
225
- <span class="ruby-comment cmt">#</span>
226
- <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>)
227
- <span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'pattern'</span>]
228
- <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>)
229
- <span class="ruby-keyword kw">begin</span>
230
- <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">compile</span>(<span class="ruby-identifier">pat</span>)
231
- <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">RegexpError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>
232
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;#{path}/pattern&quot;</span>, <span class="ruby-identifier">val</span>)
233
- <span class="ruby-keyword kw">end</span>
234
- <span class="ruby-keyword kw">end</span>
235
- <span class="ruby-comment cmt">#</span>
236
- <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>)
237
- <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>)
238
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
239
- <span class="ruby-keyword kw">else</span>
240
- <span class="ruby-comment cmt">#elem_table = {}</span>
241
- <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>
242
- <span class="ruby-comment cmt">#if elem_table[elem]</span>
243
- <span class="ruby-comment cmt"># errors &lt;&lt; validate_error(:enum_duplicate, rule, &quot;#{path}/enum&quot;, elem.to_s)</span>
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">&lt;&lt;</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">&quot;#{path}/enum&quot;</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 &lt;&lt; validate_error(:assert_noval, rule, &quot;#{path}/assert&quot;, val)</span>
256
- <span class="ruby-keyword kw">begin</span>
257
- <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;proc { |val| #{val} }&quot;</span>
258
- <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SyntaxError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>
259
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;#{path}/assert&quot;</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">&quot;/range&quot;</span>
266
- <span class="ruby-comment cmt">#if ! val.is_a?(Hash)</span>
267
- <span class="ruby-comment cmt"># errors &lt;&lt; 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">&lt;&lt;</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">&lt;&lt;</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">&quot;#{curr_path}/#{rkey}&quot;</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 &lt;&lt; validate_error(:range_undefined, rule, curr_path, &quot;#{rkey}:&quot;)</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">&amp;&amp;</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">&lt;&lt;</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">&amp;&amp;</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">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">min</span>
293
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">min_ex</span>
295
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">min</span>
299
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">min_ex</span>
301
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;/length&quot;</span>
309
- <span class="ruby-comment cmt">#val.is_a?(Hash) or errors &lt;&lt; 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">&lt;&lt;</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 &lt;&lt; validate_error(:length_notint, rule, &quot;#{curr_path}/#{lkey}&quot;, 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 &lt;&lt; validate_error(:length_undefined, rule, curr_path, &quot;#{lkey}:&quot;)</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">&quot;MAIN&quot;</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 &lt;&lt; validate_error(:type_unknown, rule, &quot;#{path}/type&quot;, 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">&lt;&lt;</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">&quot;#{path}/class&quot;</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">&gt;</span> <span class="ruby-identifier">ex</span>
236
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;#{path}/pattern&quot;</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">&lt;&lt;</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 &lt;&lt; validate_error(:enum_duplicate, rule, &quot;#{path}/enum&quot;, elem.to_s)</span>
322
248
  <span class="ruby-comment cmt">#end</span>
323
- <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">&amp;&amp;</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'max-ex'</span>)
324
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
325
- <span class="ruby-keyword kw">end</span>
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">&amp;&amp;</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">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">min</span>
332
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">min_ex</span>
334
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">min</span>
338
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">min_ex</span>
340
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</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">&lt;&lt;</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">&quot;unique:&quot;</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">&lt;&lt;</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">&quot;/&quot;</span>, <span class="ruby-value str">&quot;unique:&quot;</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">&amp;&amp;</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">&lt;&lt;</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">&quot;ident:&quot;</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">&lt;&lt;</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">&quot;#{path}/enum&quot;</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
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">empty?</span>
359
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;/&quot;</span>, <span class="ruby-value str">&quot;ident:&quot;</span>)
360
- <span class="ruby-keyword kw">end</span>
361
- <span class="ruby-keyword kw">end</span>
362
- <span class="ruby-comment cmt">#</span>
363
- <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>)
364
- <span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'sequence'</span>]
365
- <span class="ruby-comment cmt">#if val != nil &amp;&amp; !val.is_a?(Array)</span>
366
- <span class="ruby-comment cmt"># errors &lt;&lt; validate_error(:sequence_notseq, rule, &quot;#{path}/sequence&quot;, val)</span>
367
- <span class="ruby-comment cmt">#elsif ...</span>
368
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">empty?</span>
369
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;#{path}/sequence&quot;</span>, <span class="ruby-identifier">val</span>)
370
- <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
371
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;#{path}/sequence&quot;</span>, <span class="ruby-identifier">val</span>)
372
- <span class="ruby-keyword kw">else</span>
373
- <span class="ruby-identifier">elem</span> = <span class="ruby-identifier">val</span>[<span class="ruby-value">0</span>]
374
- <span class="ruby-identifier">assert_error</span>(<span class="ruby-node">&quot;elem.class=#{elem.class}&quot;</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>)
375
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">elem</span>[<span class="ruby-value str">'ident'</span>] <span class="ruby-operator">&amp;&amp;</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>
376
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;#{path}/sequence/0&quot;</span>, <span class="ruby-value str">'ident:'</span>)
377
- <span class="ruby-keyword kw">end</span>
378
- <span class="ruby-keyword kw">end</span>
379
- <span class="ruby-keyword kw">end</span>
380
- <span class="ruby-comment cmt">#</span>
381
- <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>)
382
- <span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'mapping'</span>]
383
- <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</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>)
384
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;#{path}/mapping&quot;</span>, <span class="ruby-identifier">val</span>)
385
- <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">val</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">val</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">val</span>.<span class="ruby-identifier">default</span>)
386
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;#{path}/mapping&quot;</span>, <span class="ruby-identifier">val</span>)
387
- <span class="ruby-keyword kw">end</span>
388
- <span class="ruby-keyword kw">end</span>
389
- <span class="ruby-comment cmt">#</span>
390
- <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>
391
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
392
- <span class="ruby-comment cmt">#errors &lt;&lt; validate_error(:seq_conflict, rule, path, 'enum:') if hash.key?('enum')</span>
393
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
394
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
395
- <span class="ruby-comment cmt">#errors &lt;&lt; validate_error(:seq_conflict, rule, path, 'range:') if hash.key?('range')</span>
396
- <span class="ruby-comment cmt">#errors &lt;&lt; validate_error(:seq_conflict, rule, path, 'length:') if hash.key?('length')</span>
397
- <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>
398
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
399
- <span class="ruby-comment cmt">#errors &lt;&lt; validate_error(:map_conflict, rule, path, 'enum:') if hash.key?('enum')</span>
400
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
401
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
402
- <span class="ruby-comment cmt">#errors &lt;&lt; validate_error(:map_conflict, rule, path, 'range:') if hash.key?('range')</span>
403
- <span class="ruby-comment cmt">#errors &lt;&lt; validate_error(:map_conflict, rule, path, 'length:') if hash.key?('length')</span>
404
- <span class="ruby-keyword kw">else</span>
405
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
406
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
407
- <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>)
408
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
409
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
410
- <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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>)
411
- <span class="ruby-keyword kw">end</span>
412
- <span class="ruby-keyword kw">end</span>
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 &lt;&lt; validate_error(:assert_noval, rule, &quot;#{path}/assert&quot;, val)</span>
260
+ <span class="ruby-keyword kw">begin</span>
261
+ <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;proc { |val| #{val} }&quot;</span>
262
+ <span class="ruby-keyword kw">rescue</span> <span class="ruby-operator">::</span><span class="ruby-constant">SyntaxError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>
263
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;#{path}/assert&quot;</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">&quot;/range&quot;</span>
270
+ <span class="ruby-comment cmt">#if ! val.is_a?(Hash)</span>
271
+ <span class="ruby-comment cmt"># errors &lt;&lt; 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">&lt;&lt;</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">&lt;&lt;</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">&quot;#{curr_path}/#{rkey}&quot;</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 &lt;&lt; validate_error(:range_undefined, rule, curr_path, &quot;#{rkey}:&quot;)</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">&amp;&amp;</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">&lt;&lt;</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">&amp;&amp;</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">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">min</span>
297
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">min_ex</span>
299
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">min</span>
303
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">min_ex</span>
305
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;/length&quot;</span>
313
+ <span class="ruby-comment cmt">#val.is_a?(Hash) or errors &lt;&lt; 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">&lt;&lt;</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 &lt;&lt; validate_error(:length_notint, rule, &quot;#{curr_path}/#{lkey}&quot;, 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 &lt;&lt; validate_error(:length_undefined, rule, curr_path, &quot;#{lkey}:&quot;)</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">&amp;&amp;</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">&lt;&lt;</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">&amp;&amp;</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">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">min</span>
336
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">min_ex</span>
338
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">min</span>
342
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">min_ex</span>
344
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&amp;&amp;</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">&lt;&lt;</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">&quot;unique:&quot;</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">&lt;&lt;</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">&quot;/&quot;</span>, <span class="ruby-value str">&quot;unique:&quot;</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">&amp;&amp;</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">&lt;&lt;</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">&quot;ident:&quot;</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">&lt;&lt;</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">&quot;/&quot;</span>, <span class="ruby-value str">&quot;ident:&quot;</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">&lt;&lt;</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">&quot;default:&quot;</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">&amp;&amp;</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">&lt;&lt;</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">&quot;#{path}/default&quot;</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? &amp;&amp; !val.is_a?(Array)</span>
379
+ <span class="ruby-comment cmt"># errors &lt;&lt; validate_error(:sequence_notseq, rule, &quot;#{path}/sequence&quot;, 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">&lt;&lt;</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">&quot;#{path}/sequence&quot;</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">&gt;</span> <span class="ruby-value">1</span>
384
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&quot;#{path}/sequence&quot;</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">&quot;elem.class=#{elem.class}&quot;</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">&amp;&amp;</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">&lt;&lt;</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">&quot;#{path}/sequence/0&quot;</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">&amp;&amp;</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">&lt;&lt;</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">&quot;#{path}/mapping&quot;</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">&amp;&amp;</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">&lt;&lt;</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">&quot;#{path}/mapping&quot;</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">&lt;&lt;</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 &lt;&lt; validate_error(:seq_conflict, rule, path, 'enum:') if hash.key?('enum')</span>
406
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&lt;&lt;</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 &lt;&lt; validate_error(:seq_conflict, rule, path, 'range:') if hash.key?('range')</span>
409
+ <span class="ruby-comment cmt">#errors &lt;&lt; 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">&lt;&lt;</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 &lt;&lt; validate_error(:map_conflict, rule, path, 'enum:') if hash.key?('enum')</span>
413
+ <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</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">&lt;&lt;</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 &lt;&lt; validate_error(:map_conflict, rule, path, 'range:') if hash.key?('range')</span>
416
+ <span class="ruby-comment cmt">#errors &lt;&lt; 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">&lt;&lt;</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">&lt;&lt;</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">&lt;&lt;</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">&lt;&lt;</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">&lt;&lt;</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">&lt;&lt;</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>