kwalify 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/ChangeLog +24 -19
  2. data/README.txt +51 -51
  3. data/bin/kwalify +2 -2
  4. data/contrib/inline-require +151 -0
  5. data/contrib/kwalify +2850 -0
  6. data/doc-api/classes/CommandOptionError.html +184 -0
  7. data/doc-api/classes/CommandOptionParser.html +325 -0
  8. data/doc-api/classes/Kwalify.html +270 -0
  9. data/doc-api/classes/Kwalify/AssertionError.html +148 -0
  10. data/doc-api/classes/Kwalify/BaseError.html +296 -0
  11. data/doc-api/classes/Kwalify/CommandOptionError.html +168 -0
  12. data/doc-api/classes/Kwalify/ErrorHelper.html +218 -0
  13. data/doc-api/classes/Kwalify/HashInterface.html +240 -0
  14. data/doc-api/classes/Kwalify/KwalifyError.html +111 -0
  15. data/doc-api/classes/Kwalify/Main.html +336 -0
  16. data/doc-api/classes/Kwalify/MetaValidator.html +432 -0
  17. data/doc-api/classes/Kwalify/Parser.html +155 -0
  18. data/doc-api/classes/Kwalify/PlainYamlParser.html +520 -0
  19. data/doc-api/classes/Kwalify/PlainYamlParser/Alias.html +165 -0
  20. data/doc-api/classes/Kwalify/Rule.html +411 -0
  21. data/doc-api/classes/Kwalify/SchemaError.html +148 -0
  22. data/doc-api/classes/Kwalify/Types.html +301 -0
  23. data/doc-api/classes/Kwalify/ValidationError.html +148 -0
  24. data/doc-api/classes/Kwalify/Validator.html +311 -0
  25. data/doc-api/classes/Kwalify/YamlParser.html +535 -0
  26. data/doc-api/classes/Kwalify/YamlSyntaxError.html +168 -0
  27. data/doc-api/classes/Test.html +107 -0
  28. data/doc-api/classes/Test/Unit.html +101 -0
  29. data/doc-api/classes/YamlHelper.html +259 -0
  30. data/doc-api/created.rid +1 -0
  31. data/doc-api/files/__/README_txt.html +179 -0
  32. data/doc-api/files/kwalify/errors_rb.html +114 -0
  33. data/doc-api/files/kwalify/main_rb.html +117 -0
  34. data/doc-api/files/kwalify/messages_rb.html +107 -0
  35. data/doc-api/files/kwalify/meta-validator_rb.html +117 -0
  36. data/doc-api/files/kwalify/rule_rb.html +116 -0
  37. data/doc-api/files/kwalify/types_rb.html +114 -0
  38. data/doc-api/files/kwalify/util/assert-text-equal_rb.html +115 -0
  39. data/doc-api/files/kwalify/util/hash-interface_rb.html +107 -0
  40. data/doc-api/files/kwalify/util/option-parser_rb.html +107 -0
  41. data/doc-api/files/kwalify/util/testcase-helper_rb.html +115 -0
  42. data/doc-api/files/kwalify/util/yaml-helper_rb.html +114 -0
  43. data/doc-api/files/kwalify/validator_rb.html +117 -0
  44. data/doc-api/files/kwalify/yaml-parser_rb.html +117 -0
  45. data/doc-api/files/kwalify_rb.html +120 -0
  46. data/doc-api/fr_class_index.html +50 -0
  47. data/doc-api/fr_file_index.html +41 -0
  48. data/doc-api/fr_method_index.html +109 -0
  49. data/doc-api/index.html +24 -0
  50. data/doc-api/rdoc-style.css +208 -0
  51. data/doc/users-guide.html +693 -193
  52. data/examples/address-book/Makefile +5 -0
  53. data/examples/address-book/address-book.schema.yaml +2 -1
  54. data/examples/invoice/Makefile +5 -0
  55. data/examples/invoice/invoice.schema.yaml +3 -2
  56. data/examples/tapkit/Makefile +5 -0
  57. data/examples/tapkit/main.rb +7 -0
  58. data/examples/tapkit/tapkit.schema.yaml +6 -1
  59. data/lib/kwalify.rb +3 -3
  60. data/lib/kwalify/errors.rb +2 -2
  61. data/lib/kwalify/main.rb +161 -84
  62. data/lib/kwalify/messages.rb +17 -11
  63. data/lib/kwalify/meta-validator.rb +11 -2
  64. data/lib/kwalify/rule.rb +13 -3
  65. data/lib/kwalify/templates/genclass-java.eruby +195 -0
  66. data/lib/kwalify/templates/genclass-ruby.eruby +84 -0
  67. data/lib/kwalify/types.rb +18 -18
  68. data/lib/kwalify/util/assert-text-equal.rb +44 -0
  69. data/lib/kwalify/util/hash-interface.rb +37 -0
  70. data/lib/kwalify/util/option-parser.rb +2 -2
  71. data/lib/kwalify/util/testcase-helper.rb +112 -0
  72. data/lib/kwalify/util/yaml-helper.rb +2 -2
  73. data/lib/kwalify/validator.rb +2 -2
  74. data/lib/kwalify/yaml-parser.rb +12 -9
  75. data/test/test-main.rb +77 -78
  76. data/test/test-main.yaml +543 -769
  77. data/test/test-metavalidator.rb +27 -47
  78. data/test/test-metavalidator.yaml +21 -2
  79. data/test/test-rule.rb +6 -39
  80. data/test/test-rule.yaml +2 -2
  81. data/test/test-validator.rb +36 -869
  82. data/test/test-validator.yaml +28 -20
  83. data/test/test-yamlparser.rb +30 -1248
  84. data/test/test-yamlparser.yaml +138 -110
  85. data/test/test.rb +33 -13
  86. data/test/tmp.dir/Context.java +40 -0
  87. data/test/tmp.dir/Group.java +33 -0
  88. data/test/tmp.dir/User.java +43 -0
  89. data/test/tmp.dir/action1.document +18 -0
  90. data/test/tmp.dir/action1.schema +32 -0
  91. data/test/tmp.dir/action2.document +18 -0
  92. data/test/tmp.dir/action2.schema +32 -0
  93. data/test/tmp.dir/emacs.document +6 -0
  94. data/test/tmp.dir/emacs.schema +6 -0
  95. data/test/tmp.dir/meta1.document +0 -0
  96. data/test/tmp.dir/meta1.schema +3 -0
  97. data/test/tmp.dir/meta2.document +0 -0
  98. data/test/tmp.dir/meta2.schema +3 -0
  99. data/test/tmp.dir/silent1.document +3 -0
  100. data/test/tmp.dir/silent1.schema +3 -0
  101. data/test/tmp.dir/silent2.document +7 -0
  102. data/test/tmp.dir/silent2.schema +3 -0
  103. data/test/tmp.dir/stream.invalid +8 -0
  104. data/test/tmp.dir/stream.schema +3 -0
  105. data/test/tmp.dir/stream.valid +8 -0
  106. data/test/tmp.dir/untabify.document +5 -0
  107. data/test/tmp.dir/untabify.schema +10 -0
  108. metadata +98 -12
  109. data/lib/kwalify/util/assert-diff.rb +0 -44
@@ -0,0 +1,111 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Kwalify::KwalifyError</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Kwalify::KwalifyError</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/kwalify/errors_rb.html">
59
+ kwalify/errors.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ StandardError
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+
86
+ </div>
87
+
88
+
89
+ <!-- if includes -->
90
+
91
+ <div id="section">
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ <!-- if method_list -->
101
+
102
+
103
+ </div>
104
+
105
+
106
+ <div id="validator-badges">
107
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
108
+ </div>
109
+
110
+ </body>
111
+ </html>
@@ -0,0 +1,336 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Kwalify::Main</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Kwalify::Main</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/kwalify/main_rb.html">
59
+ kwalify/main.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+ <div id="description">
82
+ <p>
83
+ ex.
84
+ </p>
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
98
+ </pre>
99
+
100
+ </div>
101
+
102
+
103
+ </div>
104
+
105
+ <div id="method-list">
106
+ <h3 class="section-bar">Methods</h3>
107
+
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;
114
+ </div>
115
+ </div>
116
+
117
+ </div>
118
+
119
+
120
+ <!-- if includes -->
121
+
122
+ <div id="section">
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+ <!-- if method_list -->
132
+ <div id="methods">
133
+ <h3 class="section-bar">Public Class methods</h3>
134
+
135
+ <div id="method-M000041" class="method-detail">
136
+ <a name="M000041"></a>
137
+
138
+ <div class="method-heading">
139
+ <a href="#M000041" class="method-signature">
140
+ <span class="method-name">main</span><span class="method-args">(command, argv=ARGV)</span>
141
+ </a>
142
+ </div>
143
+
144
+ <div class="method-description">
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">
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>
169
+ <span class="ruby-keyword kw">end</span>
170
+ </pre>
171
+ </div>
172
+ </div>
173
+ </div>
174
+
175
+ <div id="method-M000037" class="method-detail">
176
+ <a name="M000037"></a>
177
+
178
+ <div class="method-heading">
179
+ <a href="#M000037" class="method-signature">
180
+ <span class="method-name">new</span><span class="method-args">(command=nil)</span>
181
+ </a>
182
+ </div>
183
+
184
+ <div class="method-description">
185
+ <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
+ <pre>
189
+ <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>
199
+ <span class="ruby-keyword kw">end</span>
200
+ </pre>
201
+ </div>
202
+ </div>
203
+ </div>
204
+
205
+ <h3 class="section-bar">Public Instance methods</h3>
206
+
207
+ <div id="method-M000039" class="method-detail">
208
+ <a name="M000039"></a>
209
+
210
+ <div class="method-heading">
211
+ <a href="#M000039" class="method-signature">
212
+ <span class="method-name">_inspect</span><span class="method-args">()</span>
213
+ </a>
214
+ </div>
215
+
216
+ <div class="method-description">
217
+ <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
+ <pre>
221
+ <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>
238
+ <span class="ruby-keyword kw">end</span>
239
+ </pre>
240
+ </div>
241
+ </div>
242
+ </div>
243
+
244
+ <div id="method-M000038" class="method-detail">
245
+ <a name="M000038"></a>
246
+
247
+ <div class="method-heading">
248
+ <a href="#M000038" class="method-signature">
249
+ <span class="method-name">debug?</span><span class="method-args">()</span>
250
+ </a>
251
+ </div>
252
+
253
+ <div class="method-description">
254
+ <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
+ <pre>
258
+ <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>
262
+ </pre>
263
+ </div>
264
+ </div>
265
+ </div>
266
+
267
+ <div id="method-M000040" class="method-detail">
268
+ <a name="M000040"></a>
269
+
270
+ <div class="method-heading">
271
+ <a href="#M000040" class="method-signature">
272
+ <span class="method-name">execute</span><span class="method-args">(argv=ARGV)</span>
273
+ </a>
274
+ </div>
275
+
276
+ <div class="method-description">
277
+ <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
+ <pre>
281
+ <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>
318
+ <span class="ruby-keyword kw">end</span>
319
+ </pre>
320
+ </div>
321
+ </div>
322
+ </div>
323
+
324
+
325
+ </div>
326
+
327
+
328
+ </div>
329
+
330
+
331
+ <div id="validator-badges">
332
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
333
+ </div>
334
+
335
+ </body>
336
+ </html>
@@ -0,0 +1,432 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Kwalify::MetaValidator</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Kwalify::MetaValidator</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/kwalify/meta-validator_rb.html">
59
+ kwalify/meta-validator.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ <a href="Validator.html">
69
+ Validator
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+
83
+ <div id="description">
84
+ <p>
85
+ ex.
86
+ </p>
87
+ <pre>
88
+ meta_validator = Kwalify::MetaValidator.instance()
89
+ schema = File.load_file('schema.yaml')
90
+ errors = meta_validator.validate(schema)
91
+ if !errors.empty?
92
+ errors.each do |error|
93
+ puts &quot;[#{error.path}] #{error.message}&quot;
94
+ end
95
+ end
96
+ </pre>
97
+
98
+ </div>
99
+
100
+
101
+ </div>
102
+
103
+ <div id="method-list">
104
+ <h3 class="section-bar">Methods</h3>
105
+
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;
110
+ </div>
111
+ </div>
112
+
113
+ </div>
114
+
115
+
116
+ <!-- if includes -->
117
+
118
+ <div id="section">
119
+
120
+
121
+ <div id="constants-list">
122
+ <h3 class="section-bar">Constants</h3>
123
+
124
+ <div class="name-list">
125
+ <table summary="Constants">
126
+ <tr class="top-aligned-row context-row">
127
+ <td class="context-item-name">META_SCHEMA</td>
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>
130
+ </tr>
131
+ </table>
132
+ </div>
133
+ </div>
134
+
135
+
136
+
137
+
138
+
139
+
140
+ <!-- if method_list -->
141
+ <div id="methods">
142
+ <h3 class="section-bar">Public Class methods</h3>
143
+
144
+ <div id="method-M000061" class="method-detail">
145
+ <a name="M000061"></a>
146
+
147
+ <div class="method-heading">
148
+ <a href="#M000061" class="method-signature">
149
+ <span class="method-name">instance</span><span class="method-args">()</span>
150
+ </a>
151
+ </div>
152
+
153
+ <div class="method-description">
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">
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>
161
+ <span class="ruby-keyword kw">end</span>
162
+ </pre>
163
+ </div>
164
+ </div>
165
+ </div>
166
+
167
+ <div id="method-M000059" class="method-detail">
168
+ <a name="M000059"></a>
169
+
170
+ <div class="method-heading">
171
+ <a href="#M000059" class="method-signature">
172
+ <span class="method-name">new</span><span class="method-args">(schema, &amp;block)</span>
173
+ </a>
174
+ </div>
175
+
176
+ <div class="method-description">
177
+ <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">
180
+ <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
+ </pre>
186
+ </div>
187
+ </div>
188
+ </div>
189
+
190
+ <h3 class="section-bar">Public Instance methods</h3>
191
+
192
+ <div id="method-M000060" class="method-detail">
193
+ <a name="M000060"></a>
194
+
195
+ <div class="method-heading">
196
+ <a href="#M000060" class="method-signature">
197
+ <span class="method-name">validate_hook</span><span class="method-args">(value, rule, path, errors)</span>
198
+ </a>
199
+ </div>
200
+
201
+ <div class="method-description">
202
+ <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">
205
+ <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>
322
+ <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>)
357
+ <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
+
414
+ <span class="ruby-keyword kw">end</span>
415
+ </pre>
416
+ </div>
417
+ </div>
418
+ </div>
419
+
420
+
421
+ </div>
422
+
423
+
424
+ </div>
425
+
426
+
427
+ <div id="validator-badges">
428
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
429
+ </div>
430
+
431
+ </body>
432
+ </html>