ddao-kwalify 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. data/CHANGES.txt +243 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.txt +61 -0
  4. data/bin/kwalify +13 -0
  5. data/contrib/inline-require +153 -0
  6. data/contrib/kwalify +4159 -0
  7. data/doc-api/classes/CommandOptionError.html +184 -0
  8. data/doc-api/classes/CommandOptionParser.html +325 -0
  9. data/doc-api/classes/Kwalify.html +292 -0
  10. data/doc-api/classes/Kwalify/AssertionError.html +148 -0
  11. data/doc-api/classes/Kwalify/BaseError.html +297 -0
  12. data/doc-api/classes/Kwalify/BaseParser.html +461 -0
  13. data/doc-api/classes/Kwalify/CommandOptionError.html +168 -0
  14. data/doc-api/classes/Kwalify/ErrorHelper.html +223 -0
  15. data/doc-api/classes/Kwalify/HashInterface.html +118 -0
  16. data/doc-api/classes/Kwalify/Json.html +105 -0
  17. data/doc-api/classes/Kwalify/KwalifyError.html +111 -0
  18. data/doc-api/classes/Kwalify/Main.html +339 -0
  19. data/doc-api/classes/Kwalify/MetaValidator.html +448 -0
  20. data/doc-api/classes/Kwalify/Parser.html +155 -0
  21. data/doc-api/classes/Kwalify/PlainYamlParser.html +523 -0
  22. data/doc-api/classes/Kwalify/PlainYamlParser/Alias.html +165 -0
  23. data/doc-api/classes/Kwalify/Rule.html +433 -0
  24. data/doc-api/classes/Kwalify/SchemaError.html +148 -0
  25. data/doc-api/classes/Kwalify/SyntaxError.html +185 -0
  26. data/doc-api/classes/Kwalify/Types.html +302 -0
  27. data/doc-api/classes/Kwalify/Util.html +389 -0
  28. data/doc-api/classes/Kwalify/Util/HashLike.html +246 -0
  29. data/doc-api/classes/Kwalify/Util/OrderedHash.html +330 -0
  30. data/doc-api/classes/Kwalify/ValidationError.html +148 -0
  31. data/doc-api/classes/Kwalify/Validator.html +381 -0
  32. data/doc-api/classes/Kwalify/Yaml.html +194 -0
  33. data/doc-api/classes/Kwalify/Yaml/Parser.html +1538 -0
  34. data/doc-api/classes/Kwalify/YamlParser.html +542 -0
  35. data/doc-api/classes/Kwalify/YamlSyntaxError.html +119 -0
  36. data/doc-api/classes/Test.html +107 -0
  37. data/doc-api/classes/Test/Unit.html +101 -0
  38. data/doc-api/created.rid +1 -0
  39. data/doc-api/files/__/README_txt.html +172 -0
  40. data/doc-api/files/kwalify/errors_rb.html +114 -0
  41. data/doc-api/files/kwalify/main_rb.html +118 -0
  42. data/doc-api/files/kwalify/messages_rb.html +107 -0
  43. data/doc-api/files/kwalify/meta-validator_rb.html +117 -0
  44. data/doc-api/files/kwalify/parser/base_rb.html +116 -0
  45. data/doc-api/files/kwalify/parser/yaml_rb.html +117 -0
  46. data/doc-api/files/kwalify/rule_rb.html +116 -0
  47. data/doc-api/files/kwalify/types_rb.html +114 -0
  48. data/doc-api/files/kwalify/util/assert-text-equal_rb.html +115 -0
  49. data/doc-api/files/kwalify/util/hash-interface_rb.html +114 -0
  50. data/doc-api/files/kwalify/util/hashlike_rb.html +107 -0
  51. data/doc-api/files/kwalify/util/option-parser_rb.html +107 -0
  52. data/doc-api/files/kwalify/util/ordered-hash_rb.html +107 -0
  53. data/doc-api/files/kwalify/util/testcase-helper_rb.html +115 -0
  54. data/doc-api/files/kwalify/util_rb.html +107 -0
  55. data/doc-api/files/kwalify/validator_rb.html +117 -0
  56. data/doc-api/files/kwalify/yaml-parser_rb.html +117 -0
  57. data/doc-api/files/kwalify_rb.html +121 -0
  58. data/doc-api/fr_class_index.html +57 -0
  59. data/doc-api/fr_file_index.html +45 -0
  60. data/doc-api/fr_method_index.html +168 -0
  61. data/doc-api/index.html +24 -0
  62. data/doc-api/rdoc-style.css +208 -0
  63. data/doc/docstyle.css +188 -0
  64. data/doc/img/fig01.png +0 -0
  65. data/doc/users-guide.html +2050 -0
  66. data/examples/address-book/Makefile +10 -0
  67. data/examples/address-book/address-book.schema.yaml +45 -0
  68. data/examples/address-book/address-book.yaml +36 -0
  69. data/examples/data-binding/BABEL.data.yaml +63 -0
  70. data/examples/data-binding/BABEL.schema.yaml +31 -0
  71. data/examples/data-binding/Makefile +8 -0
  72. data/examples/data-binding/Rakefile +13 -0
  73. data/examples/data-binding/main.rb +27 -0
  74. data/examples/invoice/Makefile +9 -0
  75. data/examples/invoice/invoice.schema.yaml +43 -0
  76. data/examples/invoice/invoice.yaml +32 -0
  77. data/examples/tapkit/Makefile +10 -0
  78. data/examples/tapkit/main.rb +7 -0
  79. data/examples/tapkit/tapkit.schema.yaml +146 -0
  80. data/examples/tapkit/tapkit.yaml +85 -0
  81. data/lib/kwalify.rb +67 -0
  82. data/lib/kwalify/errors.rb +128 -0
  83. data/lib/kwalify/kwalify.schema.yaml +58 -0
  84. data/lib/kwalify/main.rb +442 -0
  85. data/lib/kwalify/messages.rb +173 -0
  86. data/lib/kwalify/meta-validator.rb +276 -0
  87. data/lib/kwalify/parser/base.rb +127 -0
  88. data/lib/kwalify/parser/yaml.rb +841 -0
  89. data/lib/kwalify/rule.rb +560 -0
  90. data/lib/kwalify/templates/genclass-java.eruby +222 -0
  91. data/lib/kwalify/templates/genclass-php.eruby +104 -0
  92. data/lib/kwalify/templates/genclass-ruby.eruby +113 -0
  93. data/lib/kwalify/types.rb +156 -0
  94. data/lib/kwalify/util.rb +157 -0
  95. data/lib/kwalify/util/assert-text-equal.rb +46 -0
  96. data/lib/kwalify/util/hash-interface.rb +18 -0
  97. data/lib/kwalify/util/hashlike.rb +51 -0
  98. data/lib/kwalify/util/option-parser.rb +220 -0
  99. data/lib/kwalify/util/ordered-hash.rb +57 -0
  100. data/lib/kwalify/util/testcase-helper.rb +112 -0
  101. data/lib/kwalify/validator.rb +282 -0
  102. data/lib/kwalify/yaml-parser.rb +870 -0
  103. data/setup.rb +1585 -0
  104. data/test/Rookbook.yaml +10 -0
  105. data/test/data/users-guide/AddressBook.java.expected +40 -0
  106. data/test/data/users-guide/BABEL.data.yaml +24 -0
  107. data/test/data/users-guide/BABEL.schema.yaml +30 -0
  108. data/test/data/users-guide/ExampleAddressBook.java +47 -0
  109. data/test/data/users-guide/Group.java.expected +24 -0
  110. data/test/data/users-guide/Person.java.expected +44 -0
  111. data/test/data/users-guide/address_book.rb +52 -0
  112. data/test/data/users-guide/address_book.schema.yaml +28 -0
  113. data/test/data/users-guide/address_book.yaml +27 -0
  114. data/test/data/users-guide/answers-schema.yaml +12 -0
  115. data/test/data/users-guide/answers-validator.rb +52 -0
  116. data/test/data/users-guide/babel_genclass.result +26 -0
  117. data/test/data/users-guide/config.schema.yaml +7 -0
  118. data/test/data/users-guide/config.yaml +4 -0
  119. data/test/data/users-guide/document01a.yaml +3 -0
  120. data/test/data/users-guide/document01b.yaml +3 -0
  121. data/test/data/users-guide/document02a.yaml +4 -0
  122. data/test/data/users-guide/document02b.yaml +4 -0
  123. data/test/data/users-guide/document03a.yaml +6 -0
  124. data/test/data/users-guide/document03b.yaml +6 -0
  125. data/test/data/users-guide/document04a.yaml +9 -0
  126. data/test/data/users-guide/document04b.yaml +9 -0
  127. data/test/data/users-guide/document05a.yaml +11 -0
  128. data/test/data/users-guide/document05b.yaml +12 -0
  129. data/test/data/users-guide/document06a.yaml +15 -0
  130. data/test/data/users-guide/document06b.yaml +16 -0
  131. data/test/data/users-guide/document07a.yaml +9 -0
  132. data/test/data/users-guide/document07b.yaml +7 -0
  133. data/test/data/users-guide/document12a.json +10 -0
  134. data/test/data/users-guide/document12b.json +6 -0
  135. data/test/data/users-guide/document13a.yaml +17 -0
  136. data/test/data/users-guide/document14a.yaml +3 -0
  137. data/test/data/users-guide/document14b.yaml +3 -0
  138. data/test/data/users-guide/document15a.yaml +6 -0
  139. data/test/data/users-guide/document15b.yaml +5 -0
  140. data/test/data/users-guide/example_address_book.rb +10 -0
  141. data/test/data/users-guide/example_address_book_java.result +32 -0
  142. data/test/data/users-guide/example_address_book_ruby.result +31 -0
  143. data/test/data/users-guide/genclass_java.result +4 -0
  144. data/test/data/users-guide/howto-validation-with-parsing.rb +28 -0
  145. data/test/data/users-guide/howto-validation.rb +25 -0
  146. data/test/data/users-guide/howto3.rb +6 -0
  147. data/test/data/users-guide/howto3.result +5 -0
  148. data/test/data/users-guide/howto3.yaml +8 -0
  149. data/test/data/users-guide/howto5_databinding.result +111 -0
  150. data/test/data/users-guide/invalid01.result +3 -0
  151. data/test/data/users-guide/invalid02.result +5 -0
  152. data/test/data/users-guide/invalid03.result +5 -0
  153. data/test/data/users-guide/invalid04.result +4 -0
  154. data/test/data/users-guide/invalid05.result +11 -0
  155. data/test/data/users-guide/invalid06.result +4 -0
  156. data/test/data/users-guide/invalid07.result +3 -0
  157. data/test/data/users-guide/invalid08.result +3 -0
  158. data/test/data/users-guide/invalid12.json +8 -0
  159. data/test/data/users-guide/invalid14.result +4 -0
  160. data/test/data/users-guide/invalid15.result +4 -0
  161. data/test/data/users-guide/loadbabel.rb +27 -0
  162. data/test/data/users-guide/loadconfig.rb +16 -0
  163. data/test/data/users-guide/loadconfig.result +6 -0
  164. data/test/data/users-guide/models.rb +22 -0
  165. data/test/data/users-guide/option_ha.result +6 -0
  166. data/test/data/users-guide/option_ha_genclass_java.result +7 -0
  167. data/test/data/users-guide/schema01.yaml +3 -0
  168. data/test/data/users-guide/schema02.yaml +12 -0
  169. data/test/data/users-guide/schema03.yaml +9 -0
  170. data/test/data/users-guide/schema04.yaml +20 -0
  171. data/test/data/users-guide/schema05.yaml +29 -0
  172. data/test/data/users-guide/schema06.yaml +11 -0
  173. data/test/data/users-guide/schema12.json +12 -0
  174. data/test/data/users-guide/schema13.yaml +13 -0
  175. data/test/data/users-guide/schema14.yaml +5 -0
  176. data/test/data/users-guide/schema15.yaml +21 -0
  177. data/test/data/users-guide/valid01.result +2 -0
  178. data/test/data/users-guide/valid02.result +2 -0
  179. data/test/data/users-guide/valid03.result +2 -0
  180. data/test/data/users-guide/valid04.result +2 -0
  181. data/test/data/users-guide/valid05.result +2 -0
  182. data/test/data/users-guide/valid06.result +2 -0
  183. data/test/data/users-guide/valid07.result +2 -0
  184. data/test/data/users-guide/valid08.result +2 -0
  185. data/test/data/users-guide/valid12.result +2 -0
  186. data/test/data/users-guide/valid13.result +2 -0
  187. data/test/data/users-guide/valid14.result +2 -0
  188. data/test/data/users-guide/valid15.result +2 -0
  189. data/test/data/users-guide/validate08.rb +37 -0
  190. data/test/test-action.rb +78 -0
  191. data/test/test-action.yaml +738 -0
  192. data/test/test-databinding.rb +83 -0
  193. data/test/test-databinding.yaml +339 -0
  194. data/test/test-main.rb +157 -0
  195. data/test/test-main.yaml +384 -0
  196. data/test/test-metavalidator.rb +80 -0
  197. data/test/test-metavalidator.yaml +1179 -0
  198. data/test/test-parser-yaml.rb +57 -0
  199. data/test/test-parser-yaml.yaml +1749 -0
  200. data/test/test-rule.rb +26 -0
  201. data/test/test-rule.yaml +317 -0
  202. data/test/test-users-guide.rb +75 -0
  203. data/test/test-validator.rb +95 -0
  204. data/test/test-validator.yaml +986 -0
  205. data/test/test-yaml-parser.rb +47 -0
  206. data/test/test-yaml-parser.yaml +1226 -0
  207. data/test/test.rb +60 -0
  208. metadata +261 -0
@@ -0,0 +1,986 @@
1
+ ##
2
+ ## $Rev: 83 $
3
+ ## $Release: 0.7.1 $
4
+ ## copyright(c) 2005-2008 kuwata-lab all rights reserved.
5
+ ##
6
+ ---
7
+ name: sequence1
8
+ desc: sequence test
9
+ checked: yes
10
+ #
11
+ schema: |
12
+ type: seq
13
+ required: true
14
+ sequence:
15
+ - type: str
16
+ required: true
17
+ #
18
+ valid: |
19
+ - foo
20
+ - bar
21
+ - baz
22
+ #
23
+ invalid: |
24
+ - foo
25
+ - bar
26
+ -
27
+ - baz
28
+ - 100
29
+ #
30
+ error: |
31
+ :required_novalue : (line 3)[/2] value required but none.
32
+ :type_unmatch : (line 5)[/4] '100': not a string.
33
+ error2: |
34
+ :required_novalue : 3:1:[/2] value required but none.
35
+ :type_unmatch : 5:1:[/4] '100': not a string.
36
+ ##
37
+ ---
38
+ name: mapping1
39
+ desc: mapping test
40
+ checked: yes
41
+ #
42
+ schema: |
43
+ type: map
44
+ required: true
45
+ mapping:
46
+ name:
47
+ type: str
48
+ required: true
49
+ email:
50
+ type: str
51
+ pattern: /@/
52
+ required: yes
53
+ age:
54
+ type: int
55
+ blood:
56
+ type: str
57
+ enum:
58
+ - A
59
+ - B
60
+ - O
61
+ - AB
62
+ birth:
63
+ type: date
64
+ #
65
+ valid: |
66
+ name: foo
67
+ email: foo@mail.com
68
+ age: 20
69
+ blood: AB
70
+ birth: 1985-01-01
71
+ #
72
+ invalid: |
73
+ nam: foo
74
+ email: foo(at)mail.com
75
+ age: twenty
76
+ blood: ab
77
+ birth: Jul 01, 1985
78
+ #
79
+ error: |
80
+ :required_nokey : (line 1)[/] key 'name:' is required.
81
+ :key_undefined : (line 1)[/nam] key 'nam:' is undefined.
82
+ :pattern_unmatch : (line 2)[/email] 'foo(at)mail.com': not matched to pattern /@/.
83
+ :type_unmatch : (line 3)[/age] 'twenty': not a integer.
84
+ :enum_notexist : (line 4)[/blood] 'ab': invalid blood value.
85
+ :type_unmatch : (line 5)[/birth] 'Jul 01, 1985': not a date.
86
+ error2: |
87
+ :required_nokey : 1:1:[/] key 'name:' is required.
88
+ :key_undefined : 1:1:[/nam] key 'nam:' is undefined.
89
+ :pattern_unmatch : 2:1:[/email] 'foo(at)mail.com': not matched to pattern /@/.
90
+ :type_unmatch : 3:1:[/age] 'twenty': not a integer.
91
+ :enum_notexist : 4:1:[/blood] 'ab': invalid blood value.
92
+ :type_unmatch : 5:1:[/birth] 'Jul 01, 1985': not a date.
93
+ ##
94
+ ---
95
+ name: nested1
96
+ desc: nest of seq and map
97
+ checked: yes
98
+ #
99
+ schema: |
100
+ type: map
101
+ required: true
102
+ mapping:
103
+ address-book:
104
+ type: seq
105
+ required: true
106
+ sequence:
107
+ - type: map
108
+ mapping:
109
+ name:
110
+ type: str
111
+ required: yes
112
+ email:
113
+ type: str
114
+ pattern: /@/
115
+ required: yes
116
+ age:
117
+ type: int
118
+ blood:
119
+ type: str
120
+ enum:
121
+ - A
122
+ - B
123
+ - O
124
+ - AB
125
+ birth:
126
+ type: date
127
+ #
128
+ valid: |
129
+ address-book:
130
+ - name: foo
131
+ email: foo@mail.com
132
+ age: 20
133
+ blood: AB
134
+ birth: 1985-01-01
135
+ - name: bar
136
+ email: foo@mail.com
137
+ #
138
+ invalid: |
139
+ address-book:
140
+ - name: foo
141
+ mail: foo@mail.com
142
+ age: twenty
143
+ blood: ab
144
+ birth: 1985/01/01
145
+ - name: bar
146
+ email: bar(at)mail.com
147
+ #
148
+ error: |
149
+ :required_nokey : (line 2)[/address-book/0] key 'email:' is required.
150
+ :key_undefined : (line 3)[/address-book/0/mail] key 'mail:' is undefined.
151
+ :type_unmatch : (line 4)[/address-book/0/age] 'twenty': not a integer.
152
+ :enum_notexist : (line 5)[/address-book/0/blood] 'ab': invalid blood value.
153
+ :type_unmatch : (line 6)[/address-book/0/birth] '1985/01/01': not a date.
154
+ :pattern_unmatch : (line 8)[/address-book/1/email] 'bar(at)mail.com': not matched to pattern /@/.
155
+ error2: |
156
+ :required_nokey : 2:5:[/address-book/0] key 'email:' is required.
157
+ :key_undefined : 3:5:[/address-book/0/mail] key 'mail:' is undefined.
158
+ :type_unmatch : 4:5:[/address-book/0/age] 'twenty': not a integer.
159
+ :enum_notexist : 5:5:[/address-book/0/blood] 'ab': invalid blood value.
160
+ :type_unmatch : 6:5:[/address-book/0/birth] '1985/01/01': not a date.
161
+ :pattern_unmatch : 8:5:[/address-book/1/email] 'bar(at)mail.com': not matched to pattern /@/.
162
+ ##
163
+ ---
164
+ name: anchor1
165
+ desc: schema with anchor
166
+ checked: yes
167
+ #
168
+ schema: |
169
+ type: seq
170
+ required: true
171
+ sequence:
172
+ - type: map
173
+ required: true
174
+ mapping:
175
+ first-name: &name
176
+ type: str
177
+ required: yes
178
+ family-name: *name
179
+ #
180
+ valid: |
181
+ - first-name: foo
182
+ family-name: Foo
183
+ - first-name: bar
184
+ family-name: Bar
185
+ #
186
+ invalid: |
187
+ - first-name: foo
188
+ last-name: Foo
189
+ - first-name: bar
190
+ family-name: 100
191
+ #
192
+ error: |
193
+ :required_nokey : (line 1)[/0] key 'family-name:' is required.
194
+ :key_undefined : (line 2)[/0/last-name] key 'last-name:' is undefined.
195
+ :type_unmatch : (line 4)[/1/family-name] '100': not a string.
196
+ error2: |
197
+ :required_nokey : 1:3:[/0] key 'family-name:' is required.
198
+ :key_undefined : 2:3:[/0/last-name] key 'last-name:' is undefined.
199
+ :type_unmatch : 4:3:[/1/family-name] '100': not a string.
200
+ ##
201
+ ---
202
+ name: anchor2
203
+ desc: schema with anchor 2
204
+ checked: yes
205
+ #
206
+ schema: |
207
+ type: map
208
+ required: true
209
+ mapping:
210
+ title: &name
211
+ type: str
212
+ required: true
213
+ address-book:
214
+ type: seq
215
+ required: true
216
+ sequence:
217
+ - type: map
218
+ mapping:
219
+ name: *name
220
+ email:
221
+ type: str
222
+ required: yes
223
+ #
224
+ valid: |
225
+ title: my friends
226
+ address-book:
227
+ - name: foo
228
+ email: foo@mail.com
229
+ - name: bar
230
+ email: bar@mail.com
231
+ #
232
+ invalid: |
233
+ title: my friends
234
+ address-book:
235
+ - name: 100
236
+ email: foo@mail.com
237
+ - first-name: bar
238
+ email: bar@mail.com
239
+ #
240
+ error: |
241
+ :type_unmatch : (line 3)[/address-book/0/name] '100': not a string.
242
+ :required_nokey : (line 5)[/address-book/1] key 'name:' is required.
243
+ :key_undefined : (line 5)[/address-book/1/first-name] key 'first-name:' is undefined.
244
+ error2: |
245
+ :type_unmatch : 3:5:[/address-book/0/name] '100': not a string.
246
+ :required_nokey : 5:5:[/address-book/1] key 'name:' is required.
247
+ :key_undefined : 5:5:[/address-book/1/first-name] key 'first-name:' is undefined.
248
+ ##
249
+ ---
250
+ name: anchor3
251
+ desc: document with anchor
252
+ checked: yes
253
+ #
254
+ schema: |
255
+ type: seq
256
+ sequence:
257
+ - &employee
258
+ type: map
259
+ mapping:
260
+ name:
261
+ type: str
262
+ post:
263
+ type: str
264
+ enum:
265
+ - exective
266
+ - manager
267
+ - clerk
268
+ supervisor: *employee
269
+ #
270
+ valid: |
271
+ - &foo
272
+ name: foo
273
+ post: exective
274
+ - &bar
275
+ name: bar
276
+ post: manager
277
+ supervisor: *foo
278
+ - &baz
279
+ name: baz
280
+ post: clerk
281
+ supervisor: *bar
282
+ - &zak
283
+ name: zak
284
+ post: clerk
285
+ supervisor: *bar
286
+ #
287
+ invalid: |
288
+ - &foo
289
+ name: 100
290
+ post: exective
291
+ supervisor: *foo
292
+ - &bar
293
+ name: foo
294
+ post: worker
295
+ supervisor: *foo
296
+ #
297
+ error: |
298
+ :type_unmatch : (line 2)[/0/name] '100': not a string.
299
+ :enum_notexist : (line 7)[/1/post] 'worker': invalid post value.
300
+ error2: |
301
+ :type_unmatch : 2:3:[/0/name] '100': not a string.
302
+ :enum_notexist : 7:3:[/1/post] 'worker': invalid post value.
303
+ ##
304
+ ---
305
+ name: range1
306
+ desc: range test && bug#?????
307
+ checked: yes
308
+ #
309
+ schema: |
310
+ type: map
311
+ mapping:
312
+ "max-only":
313
+ type: seq
314
+ sequence:
315
+ - type: number
316
+ required: yes
317
+ range: { max: 100 }
318
+ "min-only":
319
+ type: seq
320
+ sequence:
321
+ - type: number
322
+ required: yes
323
+ range: { min: 10.0 }
324
+ "max-and-min":
325
+ type: seq
326
+ sequence:
327
+ - type: number
328
+ required: yes
329
+ range: { max: 100.0, min: 10.0 }
330
+ #
331
+ valid: |
332
+ max-only:
333
+ - 100
334
+ - 100.0
335
+ min-only:
336
+ - 10
337
+ - 10.0
338
+ max-and-min:
339
+ - 100
340
+ - 10
341
+ - 100.0
342
+ - 10.0
343
+ #
344
+ invalid: |
345
+ max-only:
346
+ - 101
347
+ - 100.1
348
+ min-only:
349
+ - 9
350
+ - 9.99
351
+ max-and-min:
352
+ - 101
353
+ - 100.1
354
+ - 9
355
+ - 9.99
356
+ #
357
+ error: |
358
+ :range_toolarge : (line 2)[/max-only/0] '101': too large (> max 100).
359
+ :range_toolarge : (line 3)[/max-only/1] '100.1': too large (> max 100).
360
+ :range_toosmall : (line 5)[/min-only/0] '9': too small (< min 10.0).
361
+ :range_toosmall : (line 6)[/min-only/1] '9.99': too small (< min 10.0).
362
+ :range_toolarge : (line 8)[/max-and-min/0] '101': too large (> max 100.0).
363
+ :range_toolarge : (line 9)[/max-and-min/1] '100.1': too large (> max 100.0).
364
+ :range_toosmall : (line 10)[/max-and-min/2] '9': too small (< min 10.0).
365
+ :range_toosmall : (line 11)[/max-and-min/3] '9.99': too small (< min 10.0).
366
+ error2: |
367
+ :range_toolarge : 2:3:[/max-only/0] '101': too large (> max 100).
368
+ :range_toolarge : 3:3:[/max-only/1] '100.1': too large (> max 100).
369
+ :range_toosmall : 5:3:[/min-only/0] '9': too small (< min 10.0).
370
+ :range_toosmall : 6:3:[/min-only/1] '9.99': too small (< min 10.0).
371
+ :range_toolarge : 8:3:[/max-and-min/0] '101': too large (> max 100.0).
372
+ :range_toolarge : 9:3:[/max-and-min/1] '100.1': too large (> max 100.0).
373
+ :range_toosmall : 10:3:[/max-and-min/2] '9': too small (< min 10.0).
374
+ :range_toosmall : 11:3:[/max-and-min/3] '9.99': too small (< min 10.0).
375
+ ##
376
+ ---
377
+ name: range2
378
+ desc: range test (with max-ex and min-ex)
379
+ #
380
+ schema: |
381
+ type: map
382
+ mapping:
383
+ "max-ex-only":
384
+ type: seq
385
+ sequence:
386
+ - type: number
387
+ required: yes
388
+ range: { max-ex: 100 }
389
+ "min-ex-only":
390
+ type: seq
391
+ sequence:
392
+ - type: number
393
+ required: yes
394
+ range: { min-ex: 10.0 }
395
+ "max-ex-and-min-ex":
396
+ type: seq
397
+ sequence:
398
+ - type: number
399
+ required: yes
400
+ range: { max-ex: 100.0, min-ex: 10.0 }
401
+ #
402
+ valid: |
403
+ max-ex-only:
404
+ - 99
405
+ - 99.99999
406
+ min-ex-only:
407
+ - 11
408
+ - 10.00001
409
+ max-ex-and-min-ex:
410
+ - 99
411
+ - 11
412
+ - 99.99999
413
+ - 10.00001
414
+ #
415
+ invalid: |
416
+ max-ex-only:
417
+ - 100
418
+ - 100.0
419
+ min-ex-only:
420
+ - 10
421
+ - 10.0
422
+ max-ex-and-min-ex:
423
+ - 100
424
+ - 100.0
425
+ - 10
426
+ - 10.0
427
+ #
428
+ error: |
429
+ :range_toolargeex : (line 2)[/max-ex-only/0] '100': too large (>= max 100).
430
+ :range_toolargeex : (line 3)[/max-ex-only/1] '100.0': too large (>= max 100).
431
+ :range_toosmallex : (line 5)[/min-ex-only/0] '10': too small (<= min 10.0).
432
+ :range_toosmallex : (line 6)[/min-ex-only/1] '10.0': too small (<= min 10.0).
433
+ :range_toolargeex : (line 8)[/max-ex-and-min-ex/0] '100': too large (>= max 100.0).
434
+ :range_toolargeex : (line 9)[/max-ex-and-min-ex/1] '100.0': too large (>= max 100.0).
435
+ :range_toosmallex : (line 10)[/max-ex-and-min-ex/2] '10': too small (<= min 10.0).
436
+ :range_toosmallex : (line 11)[/max-ex-and-min-ex/3] '10.0': too small (<= min 10.0).
437
+ error2: |
438
+ :range_toolargeex : 2:3:[/max-ex-only/0] '100': too large (>= max 100).
439
+ :range_toolargeex : 3:3:[/max-ex-only/1] '100.0': too large (>= max 100).
440
+ :range_toosmallex : 5:3:[/min-ex-only/0] '10': too small (<= min 10.0).
441
+ :range_toosmallex : 6:3:[/min-ex-only/1] '10.0': too small (<= min 10.0).
442
+ :range_toolargeex : 8:3:[/max-ex-and-min-ex/0] '100': too large (>= max 100.0).
443
+ :range_toolargeex : 9:3:[/max-ex-and-min-ex/1] '100.0': too large (>= max 100.0).
444
+ :range_toosmallex : 10:3:[/max-ex-and-min-ex/2] '10': too small (<= min 10.0).
445
+ :range_toosmallex : 11:3:[/max-ex-and-min-ex/3] '10.0': too small (<= min 10.0).
446
+ ##
447
+ ---
448
+ name: range3
449
+ desc: range test (with max, min, max-ex and min-ex)
450
+ #
451
+ schema: |
452
+ type: map
453
+ mapping:
454
+ "A":
455
+ type: seq
456
+ sequence:
457
+ - type: number
458
+ required: yes
459
+ range: { max: 100, min-ex: 10.0 }
460
+ "B":
461
+ type: seq
462
+ sequence:
463
+ - type: number
464
+ required: yes
465
+ range: { min: 10, max-ex: 100.0 }
466
+ #
467
+ valid: |
468
+ A:
469
+ - 100
470
+ - 10.00001
471
+ B:
472
+ - 10
473
+ - 99.99999
474
+ #
475
+ invalid: |
476
+ A:
477
+ - 100.00001
478
+ - 10.0
479
+ B:
480
+ - 9.99999
481
+ - 100.0
482
+ #
483
+ error: |
484
+ :range_toolarge : (line 2)[/A/0] '100.00001': too large (> max 100).
485
+ :range_toosmallex : (line 3)[/A/1] '10.0': too small (<= min 10.0).
486
+ :range_toosmall : (line 5)[/B/0] '9.99999': too small (< min 10).
487
+ :range_toolargeex : (line 6)[/B/1] '100.0': too large (>= max 100.0).
488
+ error2: |
489
+ :range_toolarge : 2:3:[/A/0] '100.00001': too large (> max 100).
490
+ :range_toosmallex : 3:3:[/A/1] '10.0': too small (<= min 10.0).
491
+ :range_toosmall : 5:3:[/B/0] '9.99999': too small (< min 10).
492
+ :range_toolargeex : 6:3:[/B/1] '100.0': too large (>= max 100.0).
493
+ ##
494
+ ---
495
+ name: length1
496
+ desc: length test
497
+ #
498
+ schema: |
499
+ type: map
500
+ mapping:
501
+ "max-only":
502
+ type: seq
503
+ sequence:
504
+ - type: str
505
+ length: { max: 8 }
506
+ "min-only":
507
+ type: seq
508
+ sequence:
509
+ - type: str
510
+ length: { min: 4 }
511
+ "max-and-min":
512
+ type: seq
513
+ sequence:
514
+ - type: str
515
+ length: { max: 8, min: 4 }
516
+ #
517
+ valid: |
518
+ max-only:
519
+ - hogehoge
520
+ - a
521
+ -
522
+ min-only:
523
+ - hoge
524
+ - hogehogehogehogehoge
525
+ max-and-min:
526
+ - hogehoge
527
+ - hoge
528
+ #
529
+ invalid: |
530
+ max-only:
531
+ - hogehoge!
532
+ min-only:
533
+ - foo
534
+ -
535
+ max-and-min:
536
+ - foobarbaz
537
+ - foo
538
+ #
539
+ error: |
540
+ :length_toolong : (line 2)[/max-only/0] 'hogehoge!': too long (length 9 > max 8).
541
+ :length_tooshort : (line 4)[/min-only/0] 'foo': too short (length 3 < min 4).
542
+ :length_toolong : (line 7)[/max-and-min/0] 'foobarbaz': too long (length 9 > max 8).
543
+ :length_tooshort : (line 8)[/max-and-min/1] 'foo': too short (length 3 < min 4).
544
+ error2: |
545
+ :length_toolong : 2:3:[/max-only/0] 'hogehoge!': too long (length 9 > max 8).
546
+ :length_tooshort : 4:3:[/min-only/0] 'foo': too short (length 3 < min 4).
547
+ :length_toolong : 7:3:[/max-and-min/0] 'foobarbaz': too long (length 9 > max 8).
548
+ :length_tooshort : 8:3:[/max-and-min/1] 'foo': too short (length 3 < min 4).
549
+ ##
550
+ ---
551
+ name: length2
552
+ desc: length test (with max-ex and min-ex)
553
+ #
554
+ schema: |
555
+ type: map
556
+ mapping:
557
+ "max-ex-only":
558
+ type: seq
559
+ sequence:
560
+ - type: str
561
+ length: { max-ex: 8 }
562
+ "min-ex-only":
563
+ type: seq
564
+ sequence:
565
+ - type: str
566
+ length: { min-ex: 4 }
567
+ "max-ex-and-min-ex":
568
+ type: seq
569
+ sequence:
570
+ - type: str
571
+ length: { max-ex: 8, min-ex: 4 }
572
+ #
573
+ valid: |
574
+ max-ex-only:
575
+ - hogehog
576
+ - a
577
+ -
578
+ min-ex-only:
579
+ - hoge!
580
+ max-ex-and-min-ex:
581
+ - hogehog
582
+ - hoge!
583
+ #
584
+ invalid: |
585
+ max-ex-only:
586
+ - hogehoge
587
+ min-ex-only:
588
+ - foo!
589
+ -
590
+ max-ex-and-min-ex:
591
+ - foobarba
592
+ - foo!
593
+ #
594
+ error: |
595
+ :length_toolongex : (line 2)[/max-ex-only/0] 'hogehoge': too long (length 8 >= max 8).
596
+ :length_tooshortex : (line 4)[/min-ex-only/0] 'foo!': too short (length 4 <= min 4).
597
+ :length_toolongex : (line 7)[/max-ex-and-min-ex/0] 'foobarba': too long (length 8 >= max 8).
598
+ :length_tooshortex : (line 8)[/max-ex-and-min-ex/1] 'foo!': too short (length 4 <= min 4).
599
+ error2: |
600
+ :length_toolongex : 2:3:[/max-ex-only/0] 'hogehoge': too long (length 8 >= max 8).
601
+ :length_tooshortex : 4:3:[/min-ex-only/0] 'foo!': too short (length 4 <= min 4).
602
+ :length_toolongex : 7:3:[/max-ex-and-min-ex/0] 'foobarba': too long (length 8 >= max 8).
603
+ :length_tooshortex : 8:3:[/max-ex-and-min-ex/1] 'foo!': too short (length 4 <= min 4).
604
+ ##
605
+ ---
606
+ name: length3
607
+ desc: length test (with min, max, max-ex and min-ex)
608
+ #
609
+ schema: |
610
+ type: map
611
+ mapping:
612
+ "A":
613
+ type: seq
614
+ sequence:
615
+ - type: str
616
+ length: { max: 8, min-ex: 4 }
617
+ "B":
618
+ type: seq
619
+ sequence:
620
+ - type: str
621
+ length: { max-ex: 8, min: 4 }
622
+ #
623
+ valid: |
624
+ A:
625
+ - hogehoge
626
+ - hogeh
627
+ B:
628
+ - hogehog
629
+ - hoge
630
+ #
631
+ invalid: |
632
+ A:
633
+ - hogehoge!
634
+ - hoge
635
+ B:
636
+ - hogehoge
637
+ - hog
638
+ #
639
+ error: |
640
+ :length_toolong : (line 2)[/A/0] 'hogehoge!': too long (length 9 > max 8).
641
+ :length_tooshortex : (line 3)[/A/1] 'hoge': too short (length 4 <= min 4).
642
+ :length_toolongex : (line 5)[/B/0] 'hogehoge': too long (length 8 >= max 8).
643
+ :length_tooshort : (line 6)[/B/1] 'hog': too short (length 3 < min 4).
644
+ error2: |
645
+ :length_toolong : 2:3:[/A/0] 'hogehoge!': too long (length 9 > max 8).
646
+ :length_tooshortex : 3:3:[/A/1] 'hoge': too short (length 4 <= min 4).
647
+ :length_toolongex : 5:3:[/B/0] 'hogehoge': too long (length 8 >= max 8).
648
+ :length_tooshort : 6:3:[/B/1] 'hog': too short (length 3 < min 4).
649
+ ##
650
+ ---
651
+ name: assert1
652
+ desc: assert test
653
+ #
654
+ schema: |
655
+ type: seq
656
+ sequence:
657
+ - type: map
658
+ mapping:
659
+ "less-than":
660
+ type: number
661
+ assert: val < 8
662
+ "more-than":
663
+ type: number
664
+ assert: 3 < val
665
+ "between":
666
+ type: number
667
+ assert: 3 < val && val < 8
668
+ "except":
669
+ type: number
670
+ assert: val < 3 || 8 < val
671
+ #
672
+ valid: |
673
+ - less-than: 5
674
+ - more-than: 5
675
+ - between: 5
676
+ - except: 0
677
+ #
678
+ invalid*:
679
+ java: ~
680
+ ruby: |
681
+ - less-than: 8
682
+ - more-than: 3
683
+ - between: 2.9
684
+ - except: 3.1
685
+ #
686
+ error: |
687
+ :assert_failed : (line 1)[/0/less-than] '8': assertion expression failed (val < 8).
688
+ :assert_failed : (line 2)[/1/more-than] '3': assertion expression failed (3 < val).
689
+ :assert_failed : (line 3)[/2/between] '2.9': assertion expression failed (3 < val && val < 8).
690
+ :assert_failed : (line 4)[/3/except] '3.1': assertion expression failed (val < 3 || 8 < val).
691
+ error2: |
692
+ :assert_failed : 1:3:[/0/less-than] '8': assertion expression failed (val < 8).
693
+ :assert_failed : 2:3:[/1/more-than] '3': assertion expression failed (3 < val).
694
+ :assert_failed : 3:3:[/2/between] '2.9': assertion expression failed (3 < val && val < 8).
695
+ :assert_failed : 4:3:[/3/except] '3.1': assertion expression failed (val < 3 || 8 < val).
696
+ ##
697
+ ---
698
+ name: deftype1
699
+ desc: default type test
700
+ #
701
+ schema: |
702
+ type: seq
703
+ sequence:
704
+ - type: map
705
+ mapping:
706
+ "name":
707
+ "email":
708
+ #
709
+ valid: |
710
+ - name: foo
711
+ email: foo@mail.com
712
+ - name: bar
713
+ - email: baz@mail.com
714
+ #
715
+ invalid: |
716
+ - name: 123
717
+ email: true
718
+ - name: 3.14
719
+ - email: 2004-01-01
720
+ #
721
+ error*:
722
+ ruby: |
723
+ :type_unmatch : (line 1)[/0/name] '123': not a string.
724
+ :type_unmatch : (line 2)[/0/email] 'true': not a string.
725
+ :type_unmatch : (line 3)[/1/name] '3.14': not a string.
726
+ :type_unmatch : (line 4)[/2/email] '2004-01-01': not a string.
727
+ java: |
728
+ :type_unmatch : (line 1)[/0/name] '123': not a string.
729
+ :type_unmatch : (line 2)[/0/email] 'true': not a string.
730
+ :type_unmatch : (line 3)[/1/name] '3.14': not a string.
731
+ :type_unmatch : (line 4)[/2/email] 'Sun Feb 01 00:00:00 JST 2004': not a string.
732
+ error2*:
733
+ ruby: |
734
+ :type_unmatch : 1:3:[/0/name] '123': not a string.
735
+ :type_unmatch : 2:3:[/0/email] 'true': not a string.
736
+ :type_unmatch : 3:3:[/1/name] '3.14': not a string.
737
+ :type_unmatch : 4:3:[/2/email] '2004-01-01': not a string.
738
+ java: |
739
+ :type_unmatch : 1:3:[/0/name] '123': not a string.
740
+ :type_unmatch : 2:3:[/0/email] 'true': not a string.
741
+ :type_unmatch : 3:3:[/1/name] '3.14': not a string.
742
+ :type_unmatch : 4:3:[/2/email] 'Sun Feb 01 00:00:00 JST 2004': not a string.
743
+ ##
744
+ ---
745
+ name: ident1
746
+ desc: ident constraint test
747
+ #
748
+ schema: |
749
+ type: seq
750
+ sequence:
751
+ - type: map
752
+ mapping:
753
+ "name":
754
+ ident: yes
755
+ "age":
756
+ type: int
757
+ #
758
+ valid: |
759
+ - name: foo
760
+ age: 10
761
+ - name: bar
762
+ age: 10
763
+ - name: baz
764
+ age: 10
765
+ #
766
+ invalid: |
767
+ - name: foo
768
+ age: 10
769
+ - name: bar
770
+ age: 10
771
+ - name: bar
772
+ age: 10
773
+ #
774
+ error: |
775
+ :value_notunique : (line 5)[/2/name] 'bar': is already used at '/1/name'.
776
+ error2: |
777
+ :value_notunique : 5:3:[/2/name] 'bar': is already used at '/1/name'.
778
+ ##
779
+ ---
780
+ name: unique1
781
+ desc: unique constraint test with map
782
+ #
783
+ schema: |
784
+ type: seq
785
+ sequence:
786
+ - type: map
787
+ mapping:
788
+ "name":
789
+ unique: yes
790
+ "age":
791
+ type: int
792
+ #
793
+ valid: |
794
+ - name: foo
795
+ age: 10
796
+ - name: bar
797
+ age: 10
798
+ - name: baz
799
+ age: 10
800
+ #
801
+ invalid: |
802
+ - name: foo
803
+ age: 10
804
+ - name: bar
805
+ age: 10
806
+ - age: 10
807
+ name: bar
808
+ #
809
+ error: |
810
+ :value_notunique : (line 6)[/2/name] 'bar': is already used at '/1/name'.
811
+ error2: |
812
+ :value_notunique : 6:3:[/2/name] 'bar': is already used at '/1/name'.
813
+ ##
814
+ ---
815
+ name: unique2
816
+ desc: unique constraint test with seq
817
+ #
818
+ schema: |
819
+ type: seq
820
+ sequence:
821
+ - type: str
822
+ unique: yes
823
+ #
824
+ valid: |
825
+ - foo
826
+ - ~
827
+ - bar
828
+ - ~
829
+ - baz
830
+ #
831
+ invalid: |
832
+ - foo
833
+ - ~
834
+ - bar
835
+ - ~
836
+ - bar
837
+ #
838
+ error: |
839
+ :value_notunique : (line 5)[/4] 'bar': is already used at '/2'.
840
+ error2: |
841
+ :value_notunique : 5:1:[/4] 'bar': is already used at '/2'.
842
+ ##
843
+ ---
844
+ name: unique3
845
+ desc: unique constraint and '<<' (merge)
846
+ #
847
+ schema: |
848
+ type: seq
849
+ sequence:
850
+ - type: map
851
+ mapping:
852
+ "name": { type: str, required: yes, unique: yes }
853
+ "value": { type: any, required: yes }
854
+ #
855
+ valid: |
856
+ # no sense
857
+ - name: x1
858
+ value: 10
859
+ - name: x2
860
+ value: 20
861
+ #
862
+ invalid: |
863
+ - &a1
864
+ name: x1
865
+ value: 10
866
+ - <<: *a1
867
+ - <<: *a1 # wrong validation error
868
+ name: x3
869
+ #
870
+ error: |
871
+ :value_notunique : (line 2)[/1/name] 'x1': is already used at '/0/name'.
872
+ error2: |
873
+ :value_notunique : 4:3:[/1/name] 'x1': is already used at '/0/name'.
874
+ :value_notunique : 5:3:[/2/name] 'x1': is already used at '/0/name'.
875
+ memo: |
876
+ * '(line 2)' is not expected line number.
877
+ ##
878
+ ---
879
+ name: unique4
880
+ desc: unique constrant and anchor
881
+ #
882
+ schema: |
883
+ type: seq
884
+ sequence:
885
+ - type: map
886
+ mapping:
887
+ "name": { type: str }
888
+ "value": { type: any }
889
+ #
890
+ valid: |
891
+ # no sense
892
+ - name: x1
893
+ value: 10
894
+ - name: x2
895
+ value: 20
896
+ #
897
+ invalid: |
898
+ - &a1
899
+ name: x1
900
+ value: 10
901
+ - name: x2
902
+ value: 20
903
+ - *a1
904
+ #
905
+ error: |
906
+ # :value_notunique : (line 6)[/2/name] 'x1': is already used at '/0/name'.
907
+ error2: |
908
+ memo: |
909
+ * validation error should be reported but not reported.
910
+ ##
911
+ ---
912
+ name: default1
913
+ desc: default value of map
914
+ #
915
+ schema: |
916
+ type: map
917
+ mapping:
918
+ =:
919
+ type: number
920
+ range: { min: -10, max: 10 }
921
+ #
922
+ valid: |
923
+ value1: 0
924
+ value2: 10
925
+ value3: -10
926
+ #
927
+ invalid: |
928
+ value1: 0
929
+ value2: 20
930
+ value3: -20
931
+ error: |
932
+ :range_toolarge : (line 2)[/value2] '20': too large (> max 10).
933
+ :range_toosmall : (line 3)[/value3] '-20': too small (< min -10).
934
+ error2: |
935
+ :range_toolarge : 2:1:[/value2] '20': too large (> max 10).
936
+ :range_toosmall : 3:1:[/value3] '-20': too small (< min -10).
937
+ ##
938
+ ---
939
+ name: merge1
940
+ desc: merge maps
941
+ #
942
+ schema: |
943
+ type: map
944
+ mapping:
945
+ "group":
946
+ type: map
947
+ mapping:
948
+ "name": &name
949
+ type: str
950
+ required: yes
951
+ "email": &email
952
+ type: str
953
+ pattern: /@/
954
+ required: no
955
+ "user":
956
+ type: map
957
+ mapping:
958
+ "name":
959
+ <<: *name # merge
960
+ length: { max: 16 } # add
961
+ "email":
962
+ <<: *email # merge
963
+ required: yes # override
964
+ #
965
+ valid: |
966
+ group:
967
+ name: foo
968
+ email: foo@mail.com
969
+ user:
970
+ name: bar
971
+ email: bar@mail.com
972
+ #
973
+ invalid: |
974
+ group:
975
+ name: foo
976
+ email: foo@mail.com
977
+ user:
978
+ name: toooooo-looooong-naaaame
979
+ #
980
+ error: |
981
+ :required_nokey : (line 4)[/user] key 'email:' is required.
982
+ :length_toolong : (line 5)[/user/name] 'toooooo-looooong-naaaame': too long (length 24 > max 16).
983
+ error2: |
984
+ :required_nokey : 5:3:[/user] key 'email:' is required.
985
+ :length_toolong : 5:3:[/user/name] 'toooooo-looooong-naaaame': too long (length 24 > max 16).
986
+ ##