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
data/test/test-metavalidator.rb
CHANGED
@@ -1,71 +1,55 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 0.
|
2
|
+
### $Rev: 51 $
|
3
|
+
### $Release: 0.6.0 $
|
4
4
|
### copyright(c) 2005 kuwata-lab all rights reserved.
|
5
5
|
###
|
6
6
|
|
7
|
-
|
8
|
-
TESTDIR = File.dirname(__FILE__)
|
9
|
-
libdir = File.dirname(TESTDIR) + "/lib"
|
10
|
-
$LOAD_PATH << libdir << TESTDIR
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'test/unit'
|
14
|
-
require 'test/unit/ui/console/testrunner'
|
15
|
-
require 'kwalify'
|
16
|
-
require 'kwalify/util/assert-diff'
|
17
|
-
require 'yaml'
|
7
|
+
require File.dirname(__FILE__) + '/test.rb'
|
18
8
|
|
19
9
|
|
20
10
|
class MetaValidatorTest < Test::Unit::TestCase
|
21
11
|
|
22
12
|
## define test methods
|
23
13
|
filename = __FILE__.sub(/\.rb$/, '.yaml')
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
name = doc['name']
|
29
|
-
!@@docs.key?(name) or raise "*** test name '#{name}' is duplicated."
|
30
|
-
doc.each do |key, val|
|
31
|
-
if key =~ /(.*)\*$/
|
32
|
-
doc[$1] = val['ruby']
|
33
|
-
end
|
14
|
+
load_yaml_documents(filename) do |ydoc|
|
15
|
+
name = ydoc['name']
|
16
|
+
ydoc.each do |key, val|
|
17
|
+
ydoc[$1] = val['ruby'] if key =~ /(.*)\*$/
|
34
18
|
end
|
35
|
-
@@docs[name] = doc
|
36
19
|
s = <<-END
|
37
20
|
def test_meta_#{name}
|
38
|
-
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
|
44
|
-
_test
|
21
|
+
@name = #{ydoc['name'].inspect}
|
22
|
+
@desc = #{ydoc['desc'].inspect}
|
23
|
+
@schema = #{ydoc['schema'].inspect}
|
24
|
+
@meta_msg = #{ydoc['meta-msg'].inspect}
|
25
|
+
# @rule_msg = #{ydoc['rule-msg'].inspect}
|
26
|
+
@test_type = :meta
|
27
|
+
_test
|
45
28
|
end
|
46
29
|
END
|
47
|
-
|
30
|
+
module_eval s if ydoc['meta-msg']
|
48
31
|
s = <<-END
|
49
32
|
def test_rule_#{name}
|
50
|
-
|
51
|
-
@
|
52
|
-
@
|
53
|
-
@
|
54
|
-
|
55
|
-
@
|
56
|
-
_test
|
33
|
+
@name = #{ydoc['name'].inspect}
|
34
|
+
@desc = #{ydoc['desc'].inspect}
|
35
|
+
@schema = #{ydoc['schema'].inspect}
|
36
|
+
# @meta_msg = #{ydoc['meta-msg'].inspect}
|
37
|
+
@rule_msg = #{ydoc['rule-msg'].inspect}
|
38
|
+
@test_type = :rule
|
39
|
+
_test
|
57
40
|
end
|
58
41
|
END
|
59
|
-
|
42
|
+
module_eval s if ydoc['rule-msg']
|
60
43
|
end
|
61
44
|
|
45
|
+
|
62
46
|
## execute test
|
63
|
-
def _test(
|
47
|
+
def _test()
|
64
48
|
return if $target && $target != @name
|
65
49
|
#schema = YAML.load(@schema)
|
66
50
|
parser = Kwalify::YamlParser.new(@schema)
|
67
51
|
schema = parser.parse()
|
68
|
-
case test_type
|
52
|
+
case @test_type
|
69
53
|
when :meta
|
70
54
|
meta_validator = Kwalify::MetaValidator.instance()
|
71
55
|
errors = meta_validator.validate(schema)
|
@@ -89,12 +73,8 @@ class MetaValidatorTest < Test::Unit::TestCase
|
|
89
73
|
if $print
|
90
74
|
print actual
|
91
75
|
else
|
92
|
-
|
76
|
+
assert_text_equal(expected, actual)
|
93
77
|
end
|
94
78
|
end
|
95
79
|
|
96
80
|
end
|
97
|
-
|
98
|
-
#if $0 == __FILE__
|
99
|
-
# Test::Unit::UI::Console::TestRunner.run(MetaValidatorTest)
|
100
|
-
#end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release: 0.
|
2
|
+
## $Rev: 51 $
|
3
|
+
## $Release: 0.6.0 $
|
4
4
|
## copyright(c) 2005 kuwata-lab all rights reserved.
|
5
5
|
##
|
6
6
|
---
|
@@ -1102,3 +1102,22 @@ meta-msg: |
|
|
1102
1102
|
rule-msg: |
|
1103
1103
|
:ident_notmap : [/sequence/0/mapping/values/sequence/0] 'ident:': is available only with an element of mapping.
|
1104
1104
|
#
|
1105
|
+
---
|
1106
|
+
name: classname_notmap
|
1107
|
+
desc: classname_notmap
|
1108
|
+
schema: |
|
1109
|
+
type: map
|
1110
|
+
classname: User
|
1111
|
+
mapping:
|
1112
|
+
"name": { type: str, required: yes }
|
1113
|
+
"email": { type: str }
|
1114
|
+
"phones":
|
1115
|
+
type: seq
|
1116
|
+
classname: Phone
|
1117
|
+
sequence:
|
1118
|
+
- type: str
|
1119
|
+
|
1120
|
+
meta-msg: |
|
1121
|
+
:classname_notmap : [/mapping/phones/classname] 'classname:': available only with map type.
|
1122
|
+
rule-msg: |
|
1123
|
+
:classname_notmap : [/mapping/phones/classname] 'classname:': available only with map type.
|
data/test/test-rule.rb
CHANGED
@@ -1,51 +1,18 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 0.
|
2
|
+
### $Rev: 51 $
|
3
|
+
### $Release: 0.6.0 $
|
4
4
|
### copyright(c) 2005 kuwata-lab all rights reserved.
|
5
5
|
###
|
6
6
|
|
7
|
-
|
8
|
-
TESTDIR = File.dirname(__FILE__)
|
9
|
-
libdir = File.dirname(TESTDIR) + "/lib"
|
10
|
-
$LOAD_PATH << libdir << TESTDIR
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'test/unit'
|
14
|
-
require 'test/unit/ui/console/testrunner'
|
15
|
-
require 'kwalify'
|
16
|
-
require 'kwalify/util/assert-diff'
|
17
|
-
require 'yaml'
|
7
|
+
require File.dirname(__FILE__) + '/test.rb'
|
18
8
|
|
19
9
|
|
20
10
|
class RuleTest < Test::Unit::TestCase
|
21
11
|
|
22
12
|
## define test methods
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
YAML.load_documents(str) do |doc|
|
27
|
-
name = doc['name']
|
28
|
-
!@@docs.key?(name) or raise "*** test name '#name}' is duplicated."
|
29
|
-
@@docs[name] = doc
|
30
|
-
doc.each do |key, val|
|
31
|
-
if key =~ /\A(.*)\*\z/
|
32
|
-
doc[$1] ||= val['ruby']
|
33
|
-
end
|
34
|
-
end
|
35
|
-
doc['schema'] = YAML.load(doc['input'])
|
36
|
-
s = <<-END
|
37
|
-
def test_#{name}
|
38
|
-
doc = @@docs['#{name}']
|
39
|
-
@name = doc['name']
|
40
|
-
@desc = doc['desc']
|
41
|
-
@input = doc['input']
|
42
|
-
@schema = doc['schema']
|
43
|
-
@exception = #{doc['exception'] == nil ? 'nil' : doc['error']}
|
44
|
-
_test()
|
45
|
-
end
|
46
|
-
END
|
47
|
-
eval s
|
48
|
-
end
|
13
|
+
filename = __FILE__.sub(/\.rb$/, '.yaml')
|
14
|
+
load_yaml_testdata(filename, :lang=>'ruby')
|
15
|
+
|
49
16
|
|
50
17
|
## execute test
|
51
18
|
def _test()
|
data/test/test-rule.yaml
CHANGED
data/test/test-validator.rb
CHANGED
@@ -1,44 +1,18 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 0.
|
2
|
+
### $Rev: 51 $
|
3
|
+
### $Release: 0.6.0 $
|
4
4
|
### copyright(c) 2005 kuwata-lab all rights reserved.
|
5
5
|
###
|
6
6
|
|
7
|
-
|
8
|
-
TESTDIR = File.dirname(__FILE__)
|
9
|
-
libdir = File.dirname(TESTDIR) + "/lib"
|
10
|
-
$LOAD_PATH << libdir << TESTDIR
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'test/unit'
|
14
|
-
require 'test/unit/ui/console/testrunner'
|
15
|
-
require 'kwalify'
|
16
|
-
require 'kwalify/util/assert-diff'
|
17
|
-
require 'yaml'
|
7
|
+
require File.dirname(__FILE__) + '/test.rb'
|
18
8
|
|
19
9
|
|
20
10
|
class ValidatorTest < Test::Unit::TestCase
|
21
11
|
|
12
|
+
|
22
13
|
## define test methods
|
23
|
-
|
24
|
-
|
25
|
-
str.gsub!(/.*^__END__$/m, '')
|
26
|
-
name_table = {}
|
27
|
-
YAML.load_documents(str) do |doc|
|
28
|
-
!name_table.key?(doc['name']) or raise "*** test name '#{doc['name']}' is duplicated."
|
29
|
-
name_table[doc['name']] = true
|
30
|
-
s = <<-END
|
31
|
-
def test_#{doc['name']}
|
32
|
-
@name = #{doc['name'].dump}
|
33
|
-
@schema = #{doc['schema'].dump}
|
34
|
-
@valid = #{doc['valid'].dump}
|
35
|
-
@invalid = #{doc['invalid'].dump}
|
36
|
-
@error = #{doc['error'].dump}
|
37
|
-
_test()
|
38
|
-
end
|
39
|
-
END
|
40
|
-
eval s
|
41
|
-
end
|
14
|
+
filename = __FILE__.sub(/\.rb$/, '.yaml')
|
15
|
+
load_yaml_testdata(filename, :lang=>'ruby')
|
42
16
|
|
43
17
|
|
44
18
|
## execute test
|
@@ -48,856 +22,49 @@ class ValidatorTest < Test::Unit::TestCase
|
|
48
22
|
schema = YAML.load(@schema)
|
49
23
|
validator = Kwalify::Validator.new(schema)
|
50
24
|
error2 = @error.gsub(/\(line \d+\)/, '')
|
51
|
-
|
52
|
-
|
25
|
+
_test_by_syck_parser(validator, @valid, '' )
|
26
|
+
_test_by_syck_parser(validator, @invalid, error2)
|
53
27
|
# Kwalify::YamlParser
|
54
28
|
schema = Kwalify::YamlParser.new(@schema).parse()
|
55
29
|
validator = Kwalify::Validator.new(schema)
|
56
|
-
|
57
|
-
|
30
|
+
_test_by_kwalify_parser(validator, @valid, '' )
|
31
|
+
_test_by_kwalify_parser(validator, @invalid, @error)
|
58
32
|
end
|
59
33
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
else
|
65
|
-
document = YAML.load(input)
|
66
|
-
end
|
34
|
+
|
35
|
+
def _test_by_kwalify_parser(validator, input, expected)
|
36
|
+
parser = Kwalify::YamlParser.new(input)
|
37
|
+
document = parser.parse()
|
67
38
|
error_list = validator.validate(document)
|
68
|
-
|
39
|
+
parser.set_errors_linenum(error_list)
|
40
|
+
error_list.sort!
|
41
|
+
actual = ''
|
69
42
|
error_list.each do |error|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
actual << "%-20s: (line %d)[%s] %s\n" % [errsym, linenum, error.path, error.message]
|
74
|
-
else
|
75
|
-
actual << "%-20s: [%s] %s\n" % [errsym, error.path, error.message]
|
76
|
-
end
|
43
|
+
e = error
|
44
|
+
args = [e.error_symbol.inspect, e.linenum, e.path, e.message]
|
45
|
+
actual << "%-20s: (line %d)[%s] %s\n" % args
|
77
46
|
end
|
78
47
|
if $print
|
79
48
|
print actual
|
80
49
|
else
|
81
|
-
|
50
|
+
assert_text_equal(expected, actual)
|
82
51
|
end
|
83
52
|
end
|
84
53
|
|
85
|
-
end
|
86
54
|
|
87
|
-
|
88
|
-
|
89
|
-
|
55
|
+
def _test_by_syck_parser(validator, input, expected)
|
56
|
+
document = YAML.load(input)
|
57
|
+
error_list = validator.validate(document)
|
58
|
+
expected = expected.to_a.sort.join()
|
59
|
+
actual = error_list.collect { |e|
|
60
|
+
"%-20s: [%s] %s\n" % [e.error_symbol.inspect, e.path, e.message]
|
61
|
+
}.sort.join()
|
62
|
+
if $print
|
63
|
+
print actual
|
64
|
+
else
|
65
|
+
assert_text_equal(expected, actual)
|
66
|
+
end
|
67
|
+
end
|
90
68
|
|
91
|
-
|
92
|
-
|
93
|
-
name: mapping1
|
94
|
-
desc: mapping test
|
95
|
-
#
|
96
|
-
schema: |
|
97
|
-
type: map
|
98
|
-
required: true
|
99
|
-
mapping:
|
100
|
-
name:
|
101
|
-
type: str
|
102
|
-
required: true
|
103
|
-
email:
|
104
|
-
type: str
|
105
|
-
pattern: /@/
|
106
|
-
required: yes
|
107
|
-
age:
|
108
|
-
type: int
|
109
|
-
blood:
|
110
|
-
type: str
|
111
|
-
enum:
|
112
|
-
- A
|
113
|
-
- B
|
114
|
-
- O
|
115
|
-
- AB
|
116
|
-
birth:
|
117
|
-
type: date
|
118
|
-
#
|
119
|
-
valid: |
|
120
|
-
name: foo
|
121
|
-
email: foo@mail.com
|
122
|
-
age: 20
|
123
|
-
blood: AB
|
124
|
-
birth: 1985-01-01
|
125
|
-
#
|
126
|
-
invalid: |
|
127
|
-
nam: foo
|
128
|
-
email: foo(at)mail.com
|
129
|
-
age: twenty
|
130
|
-
blood: ab
|
131
|
-
birth: Jul 01, 1985
|
132
|
-
#
|
133
|
-
error: |
|
134
|
-
:required_nokey : (line 1)[/] key 'name:' is required.
|
135
|
-
:key_undefined : (line 1)[/nam] key 'nam:' is undefined.
|
136
|
-
:enum_notexist : (line 4)[/blood] 'ab': invalid blood value.
|
137
|
-
:type_unmatch : (line 5)[/birth] 'Jul 01, 1985': not a date.
|
138
|
-
:type_unmatch : (line 3)[/age] 'twenty': not a integer.
|
139
|
-
:pattern_unmatch : (line 2)[/email] 'foo(at)mail.com': not matched to pattern /@/.
|
140
|
-
#
|
141
|
-
---
|
142
|
-
name: sequence1
|
143
|
-
desc: sequence test
|
144
|
-
#
|
145
|
-
schema: |
|
146
|
-
type: seq
|
147
|
-
required: true
|
148
|
-
sequence:
|
149
|
-
- type: str
|
150
|
-
required: true
|
151
|
-
#
|
152
|
-
valid: |
|
153
|
-
- foo
|
154
|
-
- bar
|
155
|
-
- baz
|
156
|
-
#
|
157
|
-
invalid: |
|
158
|
-
- foo
|
159
|
-
- bar
|
160
|
-
-
|
161
|
-
- baz
|
162
|
-
- 100
|
163
|
-
#
|
164
|
-
error: |
|
165
|
-
:required_novalue : (line 3)[/2] value required but none.
|
166
|
-
:type_unmatch : (line 5)[/4] '100': not a string.
|
167
|
-
#
|
168
|
-
---
|
169
|
-
name: nested1
|
170
|
-
desc: nest of seq and map
|
171
|
-
#
|
172
|
-
schema: |
|
173
|
-
type: map
|
174
|
-
required: true
|
175
|
-
mapping:
|
176
|
-
address-book:
|
177
|
-
type: seq
|
178
|
-
required: true
|
179
|
-
sequence:
|
180
|
-
- type: map
|
181
|
-
mapping:
|
182
|
-
name:
|
183
|
-
type: str
|
184
|
-
required: yes
|
185
|
-
email:
|
186
|
-
type: str
|
187
|
-
pattern: /@/
|
188
|
-
required: yes
|
189
|
-
age:
|
190
|
-
type: int
|
191
|
-
blood:
|
192
|
-
type: str
|
193
|
-
enum:
|
194
|
-
- A
|
195
|
-
- B
|
196
|
-
- O
|
197
|
-
- AB
|
198
|
-
birth:
|
199
|
-
type: date
|
200
|
-
#
|
201
|
-
valid: |
|
202
|
-
address-book:
|
203
|
-
- name: foo
|
204
|
-
email: foo@mail.com
|
205
|
-
age: 20
|
206
|
-
blood: AB
|
207
|
-
birth: 1985-01-01
|
208
|
-
- name: bar
|
209
|
-
email: foo@mail.com
|
210
|
-
#
|
211
|
-
invalid: |
|
212
|
-
address-book:
|
213
|
-
- name: foo
|
214
|
-
mail: foo@mail.com
|
215
|
-
age: twenty
|
216
|
-
blood: ab
|
217
|
-
birth: 1985/01/01
|
218
|
-
- name: bar
|
219
|
-
email: bar(at)mail.com
|
220
|
-
#
|
221
|
-
error: |
|
222
|
-
:required_nokey : (line 2)[/address-book/0] key 'email:' is required.
|
223
|
-
:key_undefined : (line 3)[/address-book/0/mail] key 'mail:' is undefined.
|
224
|
-
:enum_notexist : (line 5)[/address-book/0/blood] 'ab': invalid blood value.
|
225
|
-
:type_unmatch : (line 6)[/address-book/0/birth] '1985/01/01': not a date.
|
226
|
-
:type_unmatch : (line 4)[/address-book/0/age] 'twenty': not a integer.
|
227
|
-
:pattern_unmatch : (line 8)[/address-book/1/email] 'bar(at)mail.com': not matched to pattern /@/.
|
228
|
-
#
|
229
|
-
---
|
230
|
-
name: anchor1
|
231
|
-
desc: schema with anchor
|
232
|
-
#
|
233
|
-
schema: |
|
234
|
-
type: seq
|
235
|
-
required: true
|
236
|
-
sequence:
|
237
|
-
- type: map
|
238
|
-
required: true
|
239
|
-
mapping:
|
240
|
-
first-name: &name
|
241
|
-
type: str
|
242
|
-
required: yes
|
243
|
-
family-name: *name
|
244
|
-
#
|
245
|
-
valid: |
|
246
|
-
- first-name: foo
|
247
|
-
family-name: Foo
|
248
|
-
- first-name: bar
|
249
|
-
family-name: Bar
|
250
|
-
#
|
251
|
-
invalid: |
|
252
|
-
- first-name: foo
|
253
|
-
last-name: Foo
|
254
|
-
- first-name: bar
|
255
|
-
family-name: 100
|
256
|
-
#
|
257
|
-
error: |
|
258
|
-
:required_nokey : (line 1)[/0] key 'family-name:' is required.
|
259
|
-
:key_undefined : (line 2)[/0/last-name] key 'last-name:' is undefined.
|
260
|
-
:type_unmatch : (line 4)[/1/family-name] '100': not a string.
|
261
|
-
#
|
262
|
-
---
|
263
|
-
name: anchor2
|
264
|
-
desc: schema with anchor 2
|
265
|
-
#
|
266
|
-
schema: |
|
267
|
-
type: map
|
268
|
-
required: true
|
269
|
-
mapping:
|
270
|
-
title: &name
|
271
|
-
type: str
|
272
|
-
required: true
|
273
|
-
address-book:
|
274
|
-
type: seq
|
275
|
-
required: true
|
276
|
-
sequence:
|
277
|
-
- type: map
|
278
|
-
mapping:
|
279
|
-
name: *name
|
280
|
-
email:
|
281
|
-
type: str
|
282
|
-
required: yes
|
283
|
-
#
|
284
|
-
valid: |
|
285
|
-
title: my friends
|
286
|
-
address-book:
|
287
|
-
- name: foo
|
288
|
-
email: foo@mail.com
|
289
|
-
- name: bar
|
290
|
-
email: bar@mail.com
|
291
|
-
#
|
292
|
-
invalid: |
|
293
|
-
title: my friends
|
294
|
-
address-book:
|
295
|
-
- name: 100
|
296
|
-
email: foo@mail.com
|
297
|
-
- first-name: bar
|
298
|
-
email: bar@mail.com
|
299
|
-
#
|
300
|
-
error: |
|
301
|
-
:type_unmatch : (line 3)[/address-book/0/name] '100': not a string.
|
302
|
-
:required_nokey : (line 5)[/address-book/1] key 'name:' is required.
|
303
|
-
:key_undefined : (line 5)[/address-book/1/first-name] key 'first-name:' is undefined.
|
304
|
-
#
|
305
|
-
---
|
306
|
-
name: anchor3
|
307
|
-
desc: document with anchor
|
308
|
-
#
|
309
|
-
schema: |
|
310
|
-
type: seq
|
311
|
-
sequence:
|
312
|
-
- &employee
|
313
|
-
type: map
|
314
|
-
mapping:
|
315
|
-
name:
|
316
|
-
type: str
|
317
|
-
post:
|
318
|
-
type: str
|
319
|
-
enum:
|
320
|
-
- exective
|
321
|
-
- manager
|
322
|
-
- clerk
|
323
|
-
supervisor: *employee
|
324
|
-
#
|
325
|
-
valid: |
|
326
|
-
- &foo
|
327
|
-
name: foo
|
328
|
-
post: exective
|
329
|
-
- &bar
|
330
|
-
name: bar
|
331
|
-
post: manager
|
332
|
-
supervisor: *foo
|
333
|
-
- &baz
|
334
|
-
name: baz
|
335
|
-
post: clerk
|
336
|
-
supervisor: *bar
|
337
|
-
- &zak
|
338
|
-
name: zak
|
339
|
-
post: clerk
|
340
|
-
supervisor: *bar
|
341
|
-
#
|
342
|
-
invalid: |
|
343
|
-
- &foo
|
344
|
-
name: 100
|
345
|
-
post: exective
|
346
|
-
supervisor: *foo
|
347
|
-
- &bar
|
348
|
-
name: foo
|
349
|
-
post: worker
|
350
|
-
supervisor: *foo
|
351
|
-
#
|
352
|
-
error: |
|
353
|
-
:type_unmatch : (line 2)[/0/name] '100': not a string.
|
354
|
-
:enum_notexist : (line 7)[/1/post] 'worker': invalid post value.
|
355
|
-
#
|
356
|
-
---
|
357
|
-
name: range1
|
358
|
-
desc: range test && bug#?????
|
359
|
-
#
|
360
|
-
schema: |
|
361
|
-
type: map
|
362
|
-
mapping:
|
363
|
-
"max-only":
|
364
|
-
type: seq
|
365
|
-
sequence:
|
366
|
-
- type: number
|
367
|
-
required: yes
|
368
|
-
range: { max: 100 }
|
369
|
-
"min-only":
|
370
|
-
type: seq
|
371
|
-
sequence:
|
372
|
-
- type: number
|
373
|
-
required: yes
|
374
|
-
range: { min: 10.0 }
|
375
|
-
"max-and-min":
|
376
|
-
type: seq
|
377
|
-
sequence:
|
378
|
-
- type: number
|
379
|
-
required: yes
|
380
|
-
range: { max: 100.0, min: 10.0 }
|
381
|
-
#
|
382
|
-
valid: |
|
383
|
-
max-only:
|
384
|
-
- 100
|
385
|
-
- 100.0
|
386
|
-
min-only:
|
387
|
-
- 10
|
388
|
-
- 10.0
|
389
|
-
max-and-min:
|
390
|
-
- 100
|
391
|
-
- 10
|
392
|
-
- 100.0
|
393
|
-
- 10.0
|
394
|
-
#
|
395
|
-
invalid: |
|
396
|
-
max-only:
|
397
|
-
- 101
|
398
|
-
- 100.1
|
399
|
-
min-only:
|
400
|
-
- 9
|
401
|
-
- 9.99
|
402
|
-
max-and-min:
|
403
|
-
- 101
|
404
|
-
- 100.1
|
405
|
-
- 9
|
406
|
-
- 9.99
|
407
|
-
#
|
408
|
-
error: |
|
409
|
-
:range_toosmall : (line 5)[/min-only/0] '9': too small (< min 10.0).
|
410
|
-
:range_toosmall : (line 6)[/min-only/1] '9.99': too small (< min 10.0).
|
411
|
-
:range_toolarge : (line 8)[/max-and-min/0] '101': too large (> max 100.0).
|
412
|
-
:range_toolarge : (line 9)[/max-and-min/1] '100.1': too large (> max 100.0).
|
413
|
-
:range_toosmall : (line 10)[/max-and-min/2] '9': too small (< min 10.0).
|
414
|
-
:range_toosmall : (line 11)[/max-and-min/3] '9.99': too small (< min 10.0).
|
415
|
-
:range_toolarge : (line 2)[/max-only/0] '101': too large (> max 100).
|
416
|
-
:range_toolarge : (line 3)[/max-only/1] '100.1': too large (> max 100).
|
417
|
-
#
|
418
|
-
---
|
419
|
-
name: range2
|
420
|
-
desc: range test (with max-ex and min-ex)
|
421
|
-
#
|
422
|
-
schema: |
|
423
|
-
type: map
|
424
|
-
mapping:
|
425
|
-
"max-ex-only":
|
426
|
-
type: seq
|
427
|
-
sequence:
|
428
|
-
- type: number
|
429
|
-
required: yes
|
430
|
-
range: { max-ex: 100 }
|
431
|
-
"min-ex-only":
|
432
|
-
type: seq
|
433
|
-
sequence:
|
434
|
-
- type: number
|
435
|
-
required: yes
|
436
|
-
range: { min-ex: 10.0 }
|
437
|
-
"max-ex-and-min-ex":
|
438
|
-
type: seq
|
439
|
-
sequence:
|
440
|
-
- type: number
|
441
|
-
required: yes
|
442
|
-
range: { max-ex: 100.0, min-ex: 10.0 }
|
443
|
-
#
|
444
|
-
valid: |
|
445
|
-
max-ex-only:
|
446
|
-
- 99
|
447
|
-
- 99.99999
|
448
|
-
min-ex-only:
|
449
|
-
- 11
|
450
|
-
- 10.00001
|
451
|
-
max-ex-and-min-ex:
|
452
|
-
- 99
|
453
|
-
- 11
|
454
|
-
- 99.99999
|
455
|
-
- 10.00001
|
456
|
-
#
|
457
|
-
invalid: |
|
458
|
-
max-ex-only:
|
459
|
-
- 100
|
460
|
-
- 100.0
|
461
|
-
min-ex-only:
|
462
|
-
- 10
|
463
|
-
- 10.0
|
464
|
-
max-ex-and-min-ex:
|
465
|
-
- 100
|
466
|
-
- 100.0
|
467
|
-
- 10
|
468
|
-
- 10.0
|
469
|
-
#
|
470
|
-
error: |
|
471
|
-
:range_toosmallex : (line 5)[/min-ex-only/0] '10': too small (<= min 10.0).
|
472
|
-
:range_toosmallex : (line 6)[/min-ex-only/1] '10.0': too small (<= min 10.0).
|
473
|
-
:range_toolargeex : (line 2)[/max-ex-only/0] '100': too large (>= max 100).
|
474
|
-
:range_toolargeex : (line 3)[/max-ex-only/1] '100.0': too large (>= max 100).
|
475
|
-
:range_toolargeex : (line 8)[/max-ex-and-min-ex/0] '100': too large (>= max 100.0).
|
476
|
-
:range_toolargeex : (line 9)[/max-ex-and-min-ex/1] '100.0': too large (>= max 100.0).
|
477
|
-
:range_toosmallex : (line 10)[/max-ex-and-min-ex/2] '10': too small (<= min 10.0).
|
478
|
-
:range_toosmallex : (line 11)[/max-ex-and-min-ex/3] '10.0': too small (<= min 10.0).
|
479
|
-
#
|
480
|
-
---
|
481
|
-
name: range3
|
482
|
-
desc: range test (with max, min, max-ex and min-ex)
|
483
|
-
#
|
484
|
-
schema: |
|
485
|
-
type: map
|
486
|
-
mapping:
|
487
|
-
"A":
|
488
|
-
type: seq
|
489
|
-
sequence:
|
490
|
-
- type: number
|
491
|
-
required: yes
|
492
|
-
range: { max: 100, min-ex: 10.0 }
|
493
|
-
"B":
|
494
|
-
type: seq
|
495
|
-
sequence:
|
496
|
-
- type: number
|
497
|
-
required: yes
|
498
|
-
range: { min: 10, max-ex: 100.0 }
|
499
|
-
#
|
500
|
-
valid: |
|
501
|
-
A:
|
502
|
-
- 100
|
503
|
-
- 10.00001
|
504
|
-
B:
|
505
|
-
- 10
|
506
|
-
- 99.99999
|
507
|
-
#
|
508
|
-
invalid: |
|
509
|
-
A:
|
510
|
-
- 100.00001
|
511
|
-
- 10.0
|
512
|
-
B:
|
513
|
-
- 9.99999
|
514
|
-
- 100.0
|
515
|
-
#
|
516
|
-
error: |
|
517
|
-
:range_toolarge : (line 2)[/A/0] '100.00001': too large (> max 100).
|
518
|
-
:range_toosmallex : (line 3)[/A/1] '10.0': too small (<= min 10.0).
|
519
|
-
:range_toosmall : (line 5)[/B/0] '9.99999': too small (< min 10).
|
520
|
-
:range_toolargeex : (line 6)[/B/1] '100.0': too large (>= max 100.0).
|
521
|
-
#
|
522
|
-
---
|
523
|
-
name: length1
|
524
|
-
desc: length test
|
525
|
-
#
|
526
|
-
schema: |
|
527
|
-
type: map
|
528
|
-
mapping:
|
529
|
-
"max-only":
|
530
|
-
type: seq
|
531
|
-
sequence:
|
532
|
-
- type: text
|
533
|
-
length: { max: 8 }
|
534
|
-
"min-only":
|
535
|
-
type: seq
|
536
|
-
sequence:
|
537
|
-
- type: text
|
538
|
-
length: { min: 4 }
|
539
|
-
"max-and-min":
|
540
|
-
type: seq
|
541
|
-
sequence:
|
542
|
-
- type: text
|
543
|
-
length: { max: 8, min: 4 }
|
544
|
-
#
|
545
|
-
valid: |
|
546
|
-
max-only:
|
547
|
-
- hogehoge
|
548
|
-
- 12345678
|
549
|
-
- a
|
550
|
-
-
|
551
|
-
min-only:
|
552
|
-
- hoge
|
553
|
-
- 1234
|
554
|
-
- hogehogehogehogehoge
|
555
|
-
max-and-min:
|
556
|
-
- hogehoge
|
557
|
-
- 12345678
|
558
|
-
- hoge
|
559
|
-
- 1234
|
560
|
-
#
|
561
|
-
invalid: |
|
562
|
-
max-only:
|
563
|
-
- hogehoge!
|
564
|
-
min-only:
|
565
|
-
- foo
|
566
|
-
-
|
567
|
-
max-and-min:
|
568
|
-
- foobarbaz
|
569
|
-
- foo
|
570
|
-
#
|
571
|
-
error: |
|
572
|
-
:length_tooshort : (line 4)[/min-only/0] 'foo': too short (length 3 < min 4).
|
573
|
-
:length_toolong : (line 7)[/max-and-min/0] 'foobarbaz': too long (length 9 > max 8).
|
574
|
-
:length_tooshort : (line 8)[/max-and-min/1] 'foo': too short (length 3 < min 4).
|
575
|
-
:length_toolong : (line 2)[/max-only/0] 'hogehoge!': too long (length 9 > max 8).
|
576
|
-
#
|
577
|
-
---
|
578
|
-
name: length2
|
579
|
-
desc: length test (with max-ex and min-ex)
|
580
|
-
#
|
581
|
-
schema: |
|
582
|
-
type: map
|
583
|
-
mapping:
|
584
|
-
"max-ex-only":
|
585
|
-
type: seq
|
586
|
-
sequence:
|
587
|
-
- type: text
|
588
|
-
length: { max-ex: 8 }
|
589
|
-
"min-ex-only":
|
590
|
-
type: seq
|
591
|
-
sequence:
|
592
|
-
- type: text
|
593
|
-
length: { min-ex: 4 }
|
594
|
-
"max-ex-and-min-ex":
|
595
|
-
type: seq
|
596
|
-
sequence:
|
597
|
-
- type: text
|
598
|
-
length: { max-ex: 8, min-ex: 4 }
|
599
|
-
#
|
600
|
-
valid: |
|
601
|
-
max-ex-only:
|
602
|
-
- hogehog
|
603
|
-
- 1234567
|
604
|
-
- a
|
605
|
-
-
|
606
|
-
min-ex-only:
|
607
|
-
- hoge!
|
608
|
-
- 1234!
|
609
|
-
- hogehogehogehogehoge
|
610
|
-
max-ex-and-min-ex:
|
611
|
-
- hogehog
|
612
|
-
- 1234567
|
613
|
-
- hoge!
|
614
|
-
- 1234!
|
615
|
-
#
|
616
|
-
invalid: |
|
617
|
-
max-ex-only:
|
618
|
-
- hogehoge
|
619
|
-
min-ex-only:
|
620
|
-
- foo!
|
621
|
-
-
|
622
|
-
max-ex-and-min-ex:
|
623
|
-
- foobarba
|
624
|
-
- foo!
|
625
|
-
#
|
626
|
-
error: |
|
627
|
-
:length_tooshortex : (line 4)[/min-ex-only/0] 'foo!': too short (length 4 <= min 4).
|
628
|
-
:length_toolongex : (line 2)[/max-ex-only/0] 'hogehoge': too long (length 8 >= max 8).
|
629
|
-
:length_toolongex : (line 7)[/max-ex-and-min-ex/0] 'foobarba': too long (length 8 >= max 8).
|
630
|
-
:length_tooshortex : (line 8)[/max-ex-and-min-ex/1] 'foo!': too short (length 4 <= min 4).
|
631
|
-
#
|
632
|
-
---
|
633
|
-
name: length3
|
634
|
-
desc: length test (with min, max, max-ex and min-ex)
|
635
|
-
#
|
636
|
-
schema: |
|
637
|
-
type: map
|
638
|
-
mapping:
|
639
|
-
"A":
|
640
|
-
type: seq
|
641
|
-
sequence:
|
642
|
-
- type: text
|
643
|
-
length: { max: 8, min-ex: 4 }
|
644
|
-
"B":
|
645
|
-
type: seq
|
646
|
-
sequence:
|
647
|
-
- type: text
|
648
|
-
length: { max-ex: 8, min: 4 }
|
649
|
-
#
|
650
|
-
valid: |
|
651
|
-
A:
|
652
|
-
- hogehoge
|
653
|
-
- 12345
|
654
|
-
B:
|
655
|
-
- hogehog
|
656
|
-
- 1234
|
657
|
-
#
|
658
|
-
invalid: |
|
659
|
-
A:
|
660
|
-
- hogehoge!
|
661
|
-
- 1234
|
662
|
-
B:
|
663
|
-
- hogehoge
|
664
|
-
- 123
|
665
|
-
#
|
666
|
-
error: |
|
667
|
-
:length_toolong : (line 2)[/A/0] 'hogehoge!': too long (length 9 > max 8).
|
668
|
-
:length_tooshortex : (line 3)[/A/1] '1234': too short (length 4 <= min 4).
|
669
|
-
:length_toolongex : (line 5)[/B/0] 'hogehoge': too long (length 8 >= max 8).
|
670
|
-
:length_tooshort : (line 6)[/B/1] '123': too short (length 3 < min 4).
|
671
|
-
#
|
672
|
-
---
|
673
|
-
name: assert1
|
674
|
-
desc: assert test
|
675
|
-
#
|
676
|
-
schema: |
|
677
|
-
type: seq
|
678
|
-
sequence:
|
679
|
-
- type: map
|
680
|
-
mapping:
|
681
|
-
"less-than":
|
682
|
-
type: number
|
683
|
-
assert: val < 8
|
684
|
-
"more-than":
|
685
|
-
type: number
|
686
|
-
assert: 3 < val
|
687
|
-
"between":
|
688
|
-
type: number
|
689
|
-
assert: 3 < val && val < 8
|
690
|
-
"except":
|
691
|
-
type: number
|
692
|
-
assert: val < 3 || 8 < val
|
693
|
-
#
|
694
|
-
valid: |
|
695
|
-
- less-than: 5
|
696
|
-
- more-than: 5
|
697
|
-
- between: 5
|
698
|
-
- except: 0
|
699
|
-
#
|
700
|
-
invalid: |
|
701
|
-
- less-than: 8
|
702
|
-
- more-than: 3
|
703
|
-
- between: 2.9
|
704
|
-
- except: 3.1
|
705
|
-
#
|
706
|
-
error: |
|
707
|
-
:assert_failed : (line 1)[/0/less-than] '8': assertion expression failed (val < 8).
|
708
|
-
:assert_failed : (line 2)[/1/more-than] '3': assertion expression failed (3 < val).
|
709
|
-
:assert_failed : (line 3)[/2/between] '2.9': assertion expression failed (3 < val && val < 8).
|
710
|
-
:assert_failed : (line 4)[/3/except] '3.1': assertion expression failed (val < 3 || 8 < val).
|
711
|
-
#
|
712
|
-
---
|
713
|
-
name: deftype1
|
714
|
-
desc: default type test
|
715
|
-
#
|
716
|
-
schema: |
|
717
|
-
type: seq
|
718
|
-
sequence:
|
719
|
-
- type: map
|
720
|
-
mapping:
|
721
|
-
"name":
|
722
|
-
"email":
|
723
|
-
#
|
724
|
-
valid: |
|
725
|
-
- name: foo
|
726
|
-
email: foo@mail.com
|
727
|
-
- name: bar
|
728
|
-
- email: baz@mail.com
|
729
|
-
#
|
730
|
-
invalid: |
|
731
|
-
- name: 123
|
732
|
-
email: true
|
733
|
-
- name: 3.14
|
734
|
-
- email: 2004-01-01
|
735
|
-
#
|
736
|
-
error: |
|
737
|
-
:type_unmatch : (line 1)[/0/name] '123': not a string.
|
738
|
-
:type_unmatch : (line 2)[/0/email] 'true': not a string.
|
739
|
-
:type_unmatch : (line 3)[/1/name] '3.14': not a string.
|
740
|
-
:type_unmatch : (line 4)[/2/email] '2004-01-01': not a string.
|
741
|
-
#
|
742
|
-
---
|
743
|
-
name: ident1
|
744
|
-
desc: ident constraint test
|
745
|
-
#
|
746
|
-
schema: |
|
747
|
-
type: seq
|
748
|
-
sequence:
|
749
|
-
- type: map
|
750
|
-
mapping:
|
751
|
-
"name":
|
752
|
-
ident: yes
|
753
|
-
"age":
|
754
|
-
type: int
|
755
|
-
#
|
756
|
-
valid: |
|
757
|
-
- name: foo
|
758
|
-
age: 10
|
759
|
-
- name: bar
|
760
|
-
age: 10
|
761
|
-
- name: baz
|
762
|
-
age: 10
|
763
|
-
#
|
764
|
-
invalid: |
|
765
|
-
- name: foo
|
766
|
-
age: 10
|
767
|
-
- name: bar
|
768
|
-
age: 10
|
769
|
-
- name: bar
|
770
|
-
age: 10
|
771
|
-
#
|
772
|
-
error: |
|
773
|
-
:value_notunique : (line 5)[/2/name] 'bar': is already used at '/1/name'.
|
774
|
-
#
|
775
|
-
---
|
776
|
-
name: unique1
|
777
|
-
desc: unique constraint test with map
|
778
|
-
#
|
779
|
-
schema: |
|
780
|
-
type: seq
|
781
|
-
sequence:
|
782
|
-
- type: map
|
783
|
-
mapping:
|
784
|
-
"name":
|
785
|
-
unique: yes
|
786
|
-
"age":
|
787
|
-
type: int
|
788
|
-
#
|
789
|
-
valid: |
|
790
|
-
- name: foo
|
791
|
-
age: 10
|
792
|
-
- name: bar
|
793
|
-
age: 10
|
794
|
-
- name: baz
|
795
|
-
age: 10
|
796
|
-
#
|
797
|
-
invalid: |
|
798
|
-
- name: foo
|
799
|
-
age: 10
|
800
|
-
- name: bar
|
801
|
-
age: 10
|
802
|
-
- name: bar
|
803
|
-
age: 10
|
804
|
-
#
|
805
|
-
error: |
|
806
|
-
:value_notunique : (line 5)[/2/name] 'bar': is already used at '/1/name'.
|
807
|
-
#
|
808
|
-
---
|
809
|
-
name: unique2
|
810
|
-
desc: unique constraint test with seq
|
811
|
-
#
|
812
|
-
schema: |
|
813
|
-
type: seq
|
814
|
-
sequence:
|
815
|
-
- type: str
|
816
|
-
unique: yes
|
817
|
-
#
|
818
|
-
valid: |
|
819
|
-
- foo
|
820
|
-
- ~
|
821
|
-
- bar
|
822
|
-
- ~
|
823
|
-
- baz
|
824
|
-
#
|
825
|
-
invalid: |
|
826
|
-
- foo
|
827
|
-
- ~
|
828
|
-
- bar
|
829
|
-
- ~
|
830
|
-
- bar
|
831
|
-
#
|
832
|
-
error: |
|
833
|
-
:value_notunique : (line 5)[/4] 'bar': is already used at '/2'.
|
834
|
-
#
|
835
|
-
---
|
836
|
-
name: default1
|
837
|
-
desc: default value of map
|
838
|
-
#
|
839
|
-
schema: |
|
840
|
-
type: map
|
841
|
-
mapping:
|
842
|
-
=:
|
843
|
-
type: number
|
844
|
-
range: { min: -10, max: 10 }
|
845
|
-
#
|
846
|
-
valid: |
|
847
|
-
value1: 0
|
848
|
-
value2: 10
|
849
|
-
value3: -10
|
850
|
-
#
|
851
|
-
invalid: |
|
852
|
-
value1: 0
|
853
|
-
value2: 20
|
854
|
-
value3: -20
|
855
|
-
error: |
|
856
|
-
:range_toolarge : (line 2)[/value2] '20': too large (> max 10).
|
857
|
-
:range_toosmall : (line 3)[/value3] '-20': too small (< min -10).
|
858
|
-
---
|
859
|
-
name: merge1
|
860
|
-
desc: merge maps
|
861
|
-
#
|
862
|
-
schema: |
|
863
|
-
type: map
|
864
|
-
mapping:
|
865
|
-
"group":
|
866
|
-
type: map
|
867
|
-
mapping:
|
868
|
-
"name": &name
|
869
|
-
type: str
|
870
|
-
required: yes
|
871
|
-
"email": &email
|
872
|
-
type: str
|
873
|
-
pattern: /@/
|
874
|
-
required: no
|
875
|
-
"user":
|
876
|
-
type: map
|
877
|
-
mapping:
|
878
|
-
"name":
|
879
|
-
<<: *name # merge
|
880
|
-
length: { max: 16 } # add
|
881
|
-
"email":
|
882
|
-
<<: *email # merge
|
883
|
-
required: yes # override
|
884
|
-
#
|
885
|
-
valid: |
|
886
|
-
group:
|
887
|
-
name: foo
|
888
|
-
email: foo@mail.com
|
889
|
-
user:
|
890
|
-
name: bar
|
891
|
-
email: bar@mail.com
|
892
|
-
#
|
893
|
-
invalid: |
|
894
|
-
group:
|
895
|
-
name: foo
|
896
|
-
email: foo@mail.com
|
897
|
-
user:
|
898
|
-
name: toooooo-looooong-naaaame
|
899
|
-
#
|
900
|
-
error: |
|
901
|
-
:required_nokey : (line 4)[/user] key 'email:' is required.
|
902
|
-
:length_toolong : (line 5)[/user/name] 'toooooo-looooong-naaaame': too long (length 24 > max 16).
|
903
|
-
#
|
69
|
+
|
70
|
+
end
|