kwalify 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +24 -19
- data/README.txt +51 -51
- data/bin/kwalify +2 -2
- data/contrib/inline-require +151 -0
- data/contrib/kwalify +2850 -0
- data/doc-api/classes/CommandOptionError.html +184 -0
- data/doc-api/classes/CommandOptionParser.html +325 -0
- data/doc-api/classes/Kwalify.html +270 -0
- data/doc-api/classes/Kwalify/AssertionError.html +148 -0
- data/doc-api/classes/Kwalify/BaseError.html +296 -0
- data/doc-api/classes/Kwalify/CommandOptionError.html +168 -0
- data/doc-api/classes/Kwalify/ErrorHelper.html +218 -0
- data/doc-api/classes/Kwalify/HashInterface.html +240 -0
- data/doc-api/classes/Kwalify/KwalifyError.html +111 -0
- data/doc-api/classes/Kwalify/Main.html +336 -0
- data/doc-api/classes/Kwalify/MetaValidator.html +432 -0
- data/doc-api/classes/Kwalify/Parser.html +155 -0
- data/doc-api/classes/Kwalify/PlainYamlParser.html +520 -0
- data/doc-api/classes/Kwalify/PlainYamlParser/Alias.html +165 -0
- data/doc-api/classes/Kwalify/Rule.html +411 -0
- data/doc-api/classes/Kwalify/SchemaError.html +148 -0
- data/doc-api/classes/Kwalify/Types.html +301 -0
- data/doc-api/classes/Kwalify/ValidationError.html +148 -0
- data/doc-api/classes/Kwalify/Validator.html +311 -0
- data/doc-api/classes/Kwalify/YamlParser.html +535 -0
- data/doc-api/classes/Kwalify/YamlSyntaxError.html +168 -0
- data/doc-api/classes/Test.html +107 -0
- data/doc-api/classes/Test/Unit.html +101 -0
- data/doc-api/classes/YamlHelper.html +259 -0
- data/doc-api/created.rid +1 -0
- data/doc-api/files/__/README_txt.html +179 -0
- data/doc-api/files/kwalify/errors_rb.html +114 -0
- data/doc-api/files/kwalify/main_rb.html +117 -0
- data/doc-api/files/kwalify/messages_rb.html +107 -0
- data/doc-api/files/kwalify/meta-validator_rb.html +117 -0
- data/doc-api/files/kwalify/rule_rb.html +116 -0
- data/doc-api/files/kwalify/types_rb.html +114 -0
- data/doc-api/files/kwalify/util/assert-text-equal_rb.html +115 -0
- data/doc-api/files/kwalify/util/hash-interface_rb.html +107 -0
- data/doc-api/files/kwalify/util/option-parser_rb.html +107 -0
- data/doc-api/files/kwalify/util/testcase-helper_rb.html +115 -0
- data/doc-api/files/kwalify/util/yaml-helper_rb.html +114 -0
- data/doc-api/files/kwalify/validator_rb.html +117 -0
- data/doc-api/files/kwalify/yaml-parser_rb.html +117 -0
- data/doc-api/files/kwalify_rb.html +120 -0
- data/doc-api/fr_class_index.html +50 -0
- data/doc-api/fr_file_index.html +41 -0
- data/doc-api/fr_method_index.html +109 -0
- data/doc-api/index.html +24 -0
- data/doc-api/rdoc-style.css +208 -0
- data/doc/users-guide.html +693 -193
- data/examples/address-book/Makefile +5 -0
- data/examples/address-book/address-book.schema.yaml +2 -1
- data/examples/invoice/Makefile +5 -0
- data/examples/invoice/invoice.schema.yaml +3 -2
- data/examples/tapkit/Makefile +5 -0
- data/examples/tapkit/main.rb +7 -0
- data/examples/tapkit/tapkit.schema.yaml +6 -1
- data/lib/kwalify.rb +3 -3
- data/lib/kwalify/errors.rb +2 -2
- data/lib/kwalify/main.rb +161 -84
- data/lib/kwalify/messages.rb +17 -11
- data/lib/kwalify/meta-validator.rb +11 -2
- data/lib/kwalify/rule.rb +13 -3
- data/lib/kwalify/templates/genclass-java.eruby +195 -0
- data/lib/kwalify/templates/genclass-ruby.eruby +84 -0
- data/lib/kwalify/types.rb +18 -18
- data/lib/kwalify/util/assert-text-equal.rb +44 -0
- data/lib/kwalify/util/hash-interface.rb +37 -0
- data/lib/kwalify/util/option-parser.rb +2 -2
- data/lib/kwalify/util/testcase-helper.rb +112 -0
- data/lib/kwalify/util/yaml-helper.rb +2 -2
- data/lib/kwalify/validator.rb +2 -2
- data/lib/kwalify/yaml-parser.rb +12 -9
- data/test/test-main.rb +77 -78
- data/test/test-main.yaml +543 -769
- data/test/test-metavalidator.rb +27 -47
- data/test/test-metavalidator.yaml +21 -2
- data/test/test-rule.rb +6 -39
- data/test/test-rule.yaml +2 -2
- data/test/test-validator.rb +36 -869
- data/test/test-validator.yaml +28 -20
- data/test/test-yamlparser.rb +30 -1248
- data/test/test-yamlparser.yaml +138 -110
- data/test/test.rb +33 -13
- data/test/tmp.dir/Context.java +40 -0
- data/test/tmp.dir/Group.java +33 -0
- data/test/tmp.dir/User.java +43 -0
- data/test/tmp.dir/action1.document +18 -0
- data/test/tmp.dir/action1.schema +32 -0
- data/test/tmp.dir/action2.document +18 -0
- data/test/tmp.dir/action2.schema +32 -0
- data/test/tmp.dir/emacs.document +6 -0
- data/test/tmp.dir/emacs.schema +6 -0
- data/test/tmp.dir/meta1.document +0 -0
- data/test/tmp.dir/meta1.schema +3 -0
- data/test/tmp.dir/meta2.document +0 -0
- data/test/tmp.dir/meta2.schema +3 -0
- data/test/tmp.dir/silent1.document +3 -0
- data/test/tmp.dir/silent1.schema +3 -0
- data/test/tmp.dir/silent2.document +7 -0
- data/test/tmp.dir/silent2.schema +3 -0
- data/test/tmp.dir/stream.invalid +8 -0
- data/test/tmp.dir/stream.schema +3 -0
- data/test/tmp.dir/stream.valid +8 -0
- data/test/tmp.dir/untabify.document +5 -0
- data/test/tmp.dir/untabify.schema +10 -0
- metadata +98 -12
- 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 => ex
|
92
|
+
$stderr.puts "ERROR: #{ex.message}"
|
93
|
+
exit 1
|
94
|
+
rescue Kwalify::KwalifyError => ex
|
95
|
+
$stderr.puts "ERROR: #{ex.message}"
|
96
|
+
exit 1
|
97
|
+
end
|
98
|
+
</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>
|
110
|
+
<a href="#M000038">debug?</a>
|
111
|
+
<a href="#M000040">execute</a>
|
112
|
+
<a href="#M000041">main</a>
|
113
|
+
<a href="#M000037">new</a>
|
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">></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">></span> <span class="ruby-identifier">ex</span>
|
159
|
+
<span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"ERROR: #{ex.message}"</span>
|
160
|
+
<span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
|
161
|
+
<span class="ruby-comment cmt">#rescue => 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">"#{path}/kwalify/templates"</span>
|
197
|
+
<span class="ruby-ivar">@template_path</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">tpath</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?d</span>, <span class="ruby-identifier">tpath</span>)
|
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"><<</span> <span class="ruby-node">"command: #{@command}\n"</span>
|
225
|
+
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"options:\n"</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"><=></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"><<</span> <span class="ruby-node">" - #{key}: #{@options[key]}\n"</span>
|
228
|
+
<span class="ruby-keyword kw">end</span>
|
229
|
+
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"properties:\n"</span>
|
230
|
+
<span class="ruby-ivar">@properties</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">sort_by</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span>}.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
231
|
+
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" - #{key}: #{@properties[key]}\n"</span>
|
232
|
+
<span class="ruby-keyword kw">end</span>
|
233
|
+
<span class="ruby-comment cmt">#sb << "template_path:\n"</span>
|
234
|
+
<span class="ruby-comment cmt">#@template_path.each do |path|</span>
|
235
|
+
<span class="ruby-comment cmt"># sb << " - #{path}\n"</span>
|
236
|
+
<span class="ruby-comment cmt">#end</span>
|
237
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">sb</span>.<span class="ruby-identifier">join</span>
|
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"><<</span> <span class="ruby-identifier">_version</span>() <span class="ruby-operator"><<</span> <span class="ruby-value str">"\n"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:version</span>]
|
291
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">_usage</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:help</span>] <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">action</span>
|
292
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">_describe_properties</span>(<span class="ruby-identifier">action</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:help</span>] <span class="ruby-operator">&&</span> <span class="ruby-identifier">action</span>
|
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="schema filename is not specified."</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="command-line option '-f' or '-m' required."</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 "[#{error.path}] #{error.message}"
|
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>
|
108
|
+
<a href="#M000059">new</a>
|
109
|
+
<a href="#M000060">validate_hook</a>
|
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"><<'END' name: MAIN type: map required: yes mapping: &main-rule "name": type: str "desc": type: str "classname": type: str "type": 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 "required": type: bool "enum": type: seq sequence: - type: scalar unique: yes "pattern": type: str "assert": type: str pattern: /\bval\b/ "range": type: map mapping: "max": type: scalar "min": type: scalar "max-ex": type: scalar "min-ex": type: scalar "length": type: map mapping: "max": type: int "min": type: int "max-ex": type: int "min-ex": type: int "ident": type: bool "unique": type: bool "sequence": name: SEQUENCE type: seq sequence: - type: map mapping: *main-rule name: MAIN #required: yes "mapping": 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, &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">&</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">"MAIN"</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 << validate_error(:type_unknown, rule, "#{path}/type", 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"><<</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">"#{path}/classname"</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">></span> <span class="ruby-identifier">ex</span>
|
232
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:pattern_syntaxerr</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/pattern"</span>, <span class="ruby-identifier">val</span>)
|
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"><<</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 << validate_error(:enum_duplicate, rule, "#{path}/enum", 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"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:enum_type_unmatch</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/enum"</span>, <span class="ruby-identifier">elem</span>, [<span class="ruby-constant">Kwalify</span>.<span class="ruby-identifier">word</span>(<span class="ruby-identifier">type</span>)])
|
248
|
+
<span class="ruby-keyword kw">end</span>
|
249
|
+
<span class="ruby-keyword kw">end</span>
|
250
|
+
<span class="ruby-keyword kw">end</span>
|
251
|
+
<span class="ruby-keyword kw">end</span>
|
252
|
+
<span class="ruby-comment cmt">#</span>
|
253
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'assert'</span>)
|
254
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'assert'</span>]
|
255
|
+
<span class="ruby-comment cmt">#val =~ /\bval\b/ or errors << validate_error(:assert_noval, rule, "#{path}/assert", val)</span>
|
256
|
+
<span class="ruby-keyword kw">begin</span>
|
257
|
+
<span class="ruby-identifier">eval</span> <span class="ruby-node">"proc { |val| #{val} }"</span>
|
258
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SyntaxError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
259
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:assert_syntaxerr</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/assert"</span>, <span class="ruby-identifier">val</span>)
|
260
|
+
<span class="ruby-keyword kw">end</span>
|
261
|
+
<span class="ruby-keyword kw">end</span>
|
262
|
+
<span class="ruby-comment cmt">#</span>
|
263
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'range'</span>)
|
264
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'range'</span>]
|
265
|
+
<span class="ruby-identifier">curr_path</span> = <span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"/range"</span>
|
266
|
+
<span class="ruby-comment cmt">#if ! val.is_a?(Hash)</span>
|
267
|
+
<span class="ruby-comment cmt"># errors << validate_error(:range_notmap, rule, curr_path, val)</span>
|
268
|
+
<span class="ruby-comment cmt">#elsif ...</span>
|
269
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">Types</span>.<span class="ruby-identifier">collection_type?</span>(<span class="ruby-identifier">type</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'bool'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'any'</span>
|
270
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_notscalar</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'range:'</span>)
|
271
|
+
<span class="ruby-keyword kw">else</span>
|
272
|
+
<span class="ruby-identifier">val</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">rkey</span>, <span class="ruby-identifier">rval</span><span class="ruby-operator">|</span>
|
273
|
+
<span class="ruby-comment cmt">#case rkey</span>
|
274
|
+
<span class="ruby-comment cmt">#when 'max', 'min', 'max-ex', 'min-ex'</span>
|
275
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">rval</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-identifier">klass</span>)
|
276
|
+
<span class="ruby-identifier">typename</span> = <span class="ruby-constant">Kwalify</span>.<span class="ruby-identifier">word</span>(<span class="ruby-identifier">type</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span>
|
277
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_type_unmatch</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{curr_path}/#{rkey}"</span>, <span class="ruby-identifier">rval</span>, [<span class="ruby-identifier">typename</span>])
|
278
|
+
<span class="ruby-keyword kw">end</span>
|
279
|
+
<span class="ruby-comment cmt">#else</span>
|
280
|
+
<span class="ruby-comment cmt"># errors << validate_error(:range_undefined, rule, curr_path, "#{rkey}:")</span>
|
281
|
+
<span class="ruby-comment cmt">#end</span>
|
282
|
+
<span class="ruby-keyword kw">end</span>
|
283
|
+
<span class="ruby-keyword kw">end</span>
|
284
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'max'</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'max-ex'</span>)
|
285
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_twomax</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>)
|
286
|
+
<span class="ruby-keyword kw">end</span>
|
287
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'min'</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'min-ex'</span>)
|
288
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_twomin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>)
|
289
|
+
<span class="ruby-keyword kw">end</span>
|
290
|
+
<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min_ex</span> = <span class="ruby-identifier">val</span>[<span class="ruby-value str">'max'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'min'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'max-ex'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'min-ex'</span>]
|
291
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max</span>
|
292
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">min</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">min</span>
|
293
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_maxltmin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min</span>])
|
294
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">min_ex</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min_ex</span>
|
295
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_maxleminex</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min_ex</span>])
|
296
|
+
<span class="ruby-keyword kw">end</span>
|
297
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">max_ex</span>
|
298
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">min</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min</span>
|
299
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_maxexlemin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min</span>])
|
300
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">min_ex</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min_ex</span>
|
301
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:range_maxexleminex</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min_ex</span>])
|
302
|
+
<span class="ruby-keyword kw">end</span>
|
303
|
+
<span class="ruby-keyword kw">end</span>
|
304
|
+
<span class="ruby-keyword kw">end</span>
|
305
|
+
<span class="ruby-comment cmt">#</span>
|
306
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'length'</span>)
|
307
|
+
<span class="ruby-identifier">val</span> = <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'length'</span>]
|
308
|
+
<span class="ruby-identifier">curr_path</span> = <span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"/length"</span>
|
309
|
+
<span class="ruby-comment cmt">#val.is_a?(Hash) or errors << validate_error(:length_notmap, rule, curr_path, val)</span>
|
310
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'str'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'text'</span>
|
311
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_nottext</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'length:'</span>)
|
312
|
+
<span class="ruby-keyword kw">end</span>
|
313
|
+
<span class="ruby-comment cmt">#val.each do |lkey, lval|</span>
|
314
|
+
<span class="ruby-comment cmt"># #case lkey</span>
|
315
|
+
<span class="ruby-comment cmt"># #when 'max', 'min', 'max-ex', 'min-ex'</span>
|
316
|
+
<span class="ruby-comment cmt"># unless lval.is_a?(Integer)</span>
|
317
|
+
<span class="ruby-comment cmt"># errors << validate_error(:length_notint, rule, "#{curr_path}/#{lkey}", lval)</span>
|
318
|
+
<span class="ruby-comment cmt"># end</span>
|
319
|
+
<span class="ruby-comment cmt"># #else</span>
|
320
|
+
<span class="ruby-comment cmt"># # errors << validate_error(:length_undefined, rule, curr_path, "#{lkey}:")</span>
|
321
|
+
<span class="ruby-comment cmt"># #end</span>
|
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">&&</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"><<</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">&&</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'min-ex'</span>)
|
327
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_twomin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>)
|
328
|
+
<span class="ruby-keyword kw">end</span>
|
329
|
+
<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min_ex</span> = <span class="ruby-identifier">val</span>[<span class="ruby-value str">'max'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'min'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'max-ex'</span>], <span class="ruby-identifier">val</span>[<span class="ruby-value str">'min-ex'</span>]
|
330
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max</span>
|
331
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">min</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">min</span>
|
332
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_maxltmin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min</span>])
|
333
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">min_ex</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min_ex</span>
|
334
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_maxleminex</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max</span>, <span class="ruby-identifier">min_ex</span>])
|
335
|
+
<span class="ruby-keyword kw">end</span>
|
336
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">max_ex</span>
|
337
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">min</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min</span>
|
338
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_maxexlemin</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min</span>])
|
339
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">min_ex</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">max_ex</span> <span class="ruby-operator"><=</span> <span class="ruby-identifier">min_ex</span>
|
340
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:length_maxexleminex</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">curr_path</span>, <span class="ruby-keyword kw">nil</span>, [<span class="ruby-identifier">max_ex</span>, <span class="ruby-identifier">min_ex</span>])
|
341
|
+
<span class="ruby-keyword kw">end</span>
|
342
|
+
<span class="ruby-keyword kw">end</span>
|
343
|
+
<span class="ruby-keyword kw">end</span>
|
344
|
+
<span class="ruby-comment cmt">#</span>
|
345
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'unique'</span>)
|
346
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'unique'</span>] <span class="ruby-operator">&&</span> <span class="ruby-constant">Types</span>.<span class="ruby-identifier">collection_type?</span>(<span class="ruby-identifier">type</span>)
|
347
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:unique_notscalar</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">"unique:"</span>)
|
348
|
+
<span class="ruby-keyword kw">end</span>
|
349
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">empty?</span>
|
350
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:unique_onroot</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-value str">"/"</span>, <span class="ruby-value str">"unique:"</span>)
|
351
|
+
<span class="ruby-keyword kw">end</span>
|
352
|
+
<span class="ruby-keyword kw">end</span>
|
353
|
+
<span class="ruby-comment cmt">#</span>
|
354
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'ident'</span>)
|
355
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>[<span class="ruby-value str">'ident'</span>] <span class="ruby-operator">&&</span> <span class="ruby-constant">Types</span>.<span class="ruby-identifier">collection_type?</span>(<span class="ruby-identifier">type</span>)
|
356
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:ident_notscalar</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">"ident:"</span>)
|
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"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:ident_onroot</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-value str">"/"</span>, <span class="ruby-value str">"ident:"</span>)
|
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 && !val.is_a?(Array)</span>
|
366
|
+
<span class="ruby-comment cmt"># errors << validate_error(:sequence_notseq, rule, "#{path}/sequence", 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"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:sequence_noelem</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/sequence"</span>, <span class="ruby-identifier">val</span>)
|
370
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span>
|
371
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:sequence_toomany</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/sequence"</span>, <span class="ruby-identifier">val</span>)
|
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">"elem.class=#{elem.class}"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">elem</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
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">&&</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"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:ident_notmap</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-node">"#{path}/sequence/0"</span>, <span class="ruby-value str">'ident:'</span>)
|
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">&&</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"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:mapping_notmap</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/mapping"</span>, <span class="ruby-identifier">val</span>)
|
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">&&</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"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:mapping_noelem</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-node">"#{path}/mapping"</span>, <span class="ruby-identifier">val</span>)
|
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"><<</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 << validate_error(:seq_conflict, rule, path, 'enum:') if hash.key?('enum')</span>
|
393
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:seq_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'pattern:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'pattern'</span>)
|
394
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:seq_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'mapping:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'mapping'</span>)
|
395
|
+
<span class="ruby-comment cmt">#errors << validate_error(:seq_conflict, rule, path, 'range:') if hash.key?('range')</span>
|
396
|
+
<span class="ruby-comment cmt">#errors << 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"><<</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 << validate_error(:map_conflict, rule, path, 'enum:') if hash.key?('enum')</span>
|
400
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:map_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'pattern:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'pattern'</span>)
|
401
|
+
<span class="ruby-identifier">errors</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">validate_error</span>(<span class="ruby-identifier">:map_conflict</span>, <span class="ruby-identifier">rule</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value str">'sequence:'</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">'sequence'</span>)
|
402
|
+
<span class="ruby-comment cmt">#errors << validate_error(:map_conflict, rule, path, 'range:') if hash.key?('range')</span>
|
403
|
+
<span class="ruby-comment cmt">#errors << 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"><<</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"><<</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"><<</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"><<</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"><<</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>
|