schemacop 3.0.19 → 3.0.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8164d9dd2a81d5ec5ae76513ed811684a4d8cadeabd5b4b4781a8a73fa921461
4
- data.tar.gz: 4bd7ec87972185ada98efa998077346ace90a52cbd8f447cb245515f0089b65e
3
+ metadata.gz: 3e4a4c21714a897d8dc9d04f6ef054890c39571a200390fc727943be5012f4fe
4
+ data.tar.gz: 29f3660744d2080d928bc0645fe6da7a110f985272a5a279508f7eb85816905e
5
5
  SHA512:
6
- metadata.gz: 7a8528412066ec7cd2569750c75838dfcafc101ca3deb708bde0b866c9b161699ef1f44f26fae2a198a6dc36e7d66d038f72179e2e64b63a159dab5e9b7050a7
7
- data.tar.gz: e9354474a36a62234aa28a6186bf48b6d1c292a3b7382ccd61a0d85469dd9b50d803aad9c3b81623e4a2ae7b735c3c0ec69fc148c3407c4af67db670d96b5a32
6
+ metadata.gz: f5a5cfa4ea22c5b9203ecb7d049e15b29cb2c41ea1c4246bcab707a9265bb1769e1c645a1a7b5c7e5a8f0640c796aa154f87497d0a5b65228f512d6a14f893d8
7
+ data.tar.gz: ed8dd1f20572424c12dc1bb3b098169482a1ee887721054227d4f6111ad7fb65548e87b3a128f24b3a56ac4fbcd083de39bf25fd6b4404516850f9f2eab46711
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change log
2
2
 
3
+ ## 3.0.20 (2022-09-29)
4
+
5
+ * Improve error messages for `all_of`, `any_of` and `one_of`
6
+
3
7
  ## 3.0.19 (2022-09-19)
4
8
 
5
9
  * Make `cast_str` of `BooleanNode` in `v3` case-insensitive
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.19
1
+ 3.0.20
@@ -9,8 +9,13 @@ module Schemacop
9
9
  super_data = super
10
10
  return if super_data.nil?
11
11
 
12
- if matches(super_data).size != @items.size
13
- result.error 'Does not match all allOf conditions.'
12
+ matches = matches(super_data)
13
+
14
+ if matches.size != @items.size
15
+ result.error <<~PLAIN.strip
16
+ Matches #{matches.size} schemas but should match all of them:
17
+ #{schema_messages(data).join("\n")}
18
+ PLAIN
14
19
  end
15
20
  end
16
21
 
@@ -14,7 +14,10 @@ module Schemacop
14
14
  if match
15
15
  match._validate(super_data, result: result)
16
16
  else
17
- result.error 'Does not match any anyOf condition.'
17
+ result.error <<~PLAIN.strip
18
+ Matches 0 schemas but should match at least 1:
19
+ #{schema_messages(super_data).join("\n")}
20
+ PLAIN
18
21
  end
19
22
  end
20
23
 
@@ -40,6 +40,19 @@ module Schemacop
40
40
  def matches(data)
41
41
  @items.select { |i| item_matches?(i, data) }
42
42
  end
43
+
44
+ def schema_messages(data)
45
+ return @items.each_with_index.map do |item, index|
46
+ item_result = Result.new(self)
47
+ item._validate(data, result: item_result)
48
+ if item_result.valid?
49
+ " - Schema #{index + 1}: Matches"
50
+ else
51
+ message = " - Schema #{index + 1}:\n"
52
+ message << item_result.messages(pad: 4, itemize: true).join("\n")
53
+ end
54
+ end
55
+ end
43
56
  end
44
57
  end
45
58
  end
@@ -36,7 +36,10 @@ module Schemacop
36
36
  if matches.size == 1
37
37
  matches.first._validate(super_data, result: result)
38
38
  else
39
- result.error "Matches #{matches.size} definitions but should match exactly 1."
39
+ result.error <<~PLAIN.strip
40
+ Matches #{matches.size} schemas but should match exactly 1:
41
+ #{schema_messages(data).join("\n")}
42
+ PLAIN
40
43
  end
41
44
  end
42
45
 
@@ -35,18 +35,24 @@ module Schemacop
35
35
  messages.join("\n")
36
36
  end
37
37
 
38
- def messages
38
+ def messages(pad: 0, itemize: false)
39
39
  messages = []
40
40
 
41
+ item_str = itemize ? '- ' : nil
42
+
41
43
  @errors.each do |path, path_messages|
42
44
  messages += path_messages.map do |path_message|
43
- "/#{path.join('/')}: #{path_message}"
45
+ pad_lines("#{item_str}/#{path.join('/')}: #{path_message}", pad)
44
46
  end
45
47
  end
46
48
 
47
49
  return messages
48
50
  end
49
51
 
52
+ def pad_lines(string, pad = 2)
53
+ string.split("\n").map { |line| "#{' ' * pad}#{line}" }.join("\n")
54
+ end
55
+
50
56
  def in_path(segment)
51
57
  prev_path = @current_path
52
58
  @current_path += [segment]
data/schemacop.gemspec CHANGED
@@ -1,37 +1,49 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: schemacop 3.0.19 ruby lib
2
+ # stub: schemacop 3.0.20 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "schemacop".freeze
6
- s.version = "3.0.19"
6
+ s.version = "3.0.20"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Sitrox".freeze]
11
- s.date = "2022-09-19"
11
+ s.date = "2022-09-29"
12
12
  s.files = [".github/workflows/ruby.yml".freeze, ".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, ".yardopts".freeze, "CHANGELOG.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "README_V2.md".freeze, "README_V3.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "lib/schemacop.rb".freeze, "lib/schemacop/base_schema.rb".freeze, "lib/schemacop/exceptions.rb".freeze, "lib/schemacop/railtie.rb".freeze, "lib/schemacop/schema.rb".freeze, "lib/schemacop/schema2.rb".freeze, "lib/schemacop/schema3.rb".freeze, "lib/schemacop/scoped_env.rb".freeze, "lib/schemacop/v2.rb".freeze, "lib/schemacop/v2/caster.rb".freeze, "lib/schemacop/v2/collector.rb".freeze, "lib/schemacop/v2/dupper.rb".freeze, "lib/schemacop/v2/field_node.rb".freeze, "lib/schemacop/v2/node.rb".freeze, "lib/schemacop/v2/node_resolver.rb".freeze, "lib/schemacop/v2/node_supporting_field.rb".freeze, "lib/schemacop/v2/node_supporting_type.rb".freeze, "lib/schemacop/v2/node_with_block.rb".freeze, "lib/schemacop/v2/validator/array_validator.rb".freeze, "lib/schemacop/v2/validator/boolean_validator.rb".freeze, "lib/schemacop/v2/validator/float_validator.rb".freeze, "lib/schemacop/v2/validator/hash_validator.rb".freeze, "lib/schemacop/v2/validator/integer_validator.rb".freeze, "lib/schemacop/v2/validator/nil_validator.rb".freeze, "lib/schemacop/v2/validator/number_validator.rb".freeze, "lib/schemacop/v2/validator/object_validator.rb".freeze, "lib/schemacop/v2/validator/string_validator.rb".freeze, "lib/schemacop/v2/validator/symbol_validator.rb".freeze, "lib/schemacop/v3.rb".freeze, "lib/schemacop/v3/all_of_node.rb".freeze, "lib/schemacop/v3/any_of_node.rb".freeze, "lib/schemacop/v3/array_node.rb".freeze, "lib/schemacop/v3/boolean_node.rb".freeze, "lib/schemacop/v3/combination_node.rb".freeze, "lib/schemacop/v3/context.rb".freeze, "lib/schemacop/v3/dsl_scope.rb".freeze, "lib/schemacop/v3/global_context.rb".freeze, "lib/schemacop/v3/hash_node.rb".freeze, "lib/schemacop/v3/integer_node.rb".freeze, "lib/schemacop/v3/is_not_node.rb".freeze, "lib/schemacop/v3/node.rb".freeze, "lib/schemacop/v3/node_registry.rb".freeze, "lib/schemacop/v3/number_node.rb".freeze, "lib/schemacop/v3/numeric_node.rb".freeze, "lib/schemacop/v3/object_node.rb".freeze, "lib/schemacop/v3/one_of_node.rb".freeze, "lib/schemacop/v3/reference_node.rb".freeze, "lib/schemacop/v3/result.rb".freeze, "lib/schemacop/v3/string_node.rb".freeze, "lib/schemacop/v3/symbol_node.rb".freeze, "schemacop.gemspec".freeze, "test/lib/test_helper.rb".freeze, "test/schemas/nested/group.rb".freeze, "test/schemas/user.rb".freeze, "test/unit/schemacop/v2/casting_test.rb".freeze, "test/unit/schemacop/v2/collector_test.rb".freeze, "test/unit/schemacop/v2/custom_check_test.rb".freeze, "test/unit/schemacop/v2/custom_if_test.rb".freeze, "test/unit/schemacop/v2/defaults_test.rb".freeze, "test/unit/schemacop/v2/empty_test.rb".freeze, "test/unit/schemacop/v2/nil_dis_allow_test.rb".freeze, "test/unit/schemacop/v2/node_resolver_test.rb".freeze, "test/unit/schemacop/v2/short_forms_test.rb".freeze, "test/unit/schemacop/v2/types_test.rb".freeze, "test/unit/schemacop/v2/validator_array_test.rb".freeze, "test/unit/schemacop/v2/validator_boolean_test.rb".freeze, "test/unit/schemacop/v2/validator_float_test.rb".freeze, "test/unit/schemacop/v2/validator_hash_test.rb".freeze, "test/unit/schemacop/v2/validator_integer_test.rb".freeze, "test/unit/schemacop/v2/validator_nil_test.rb".freeze, "test/unit/schemacop/v2/validator_number_test.rb".freeze, "test/unit/schemacop/v2/validator_object_test.rb".freeze, "test/unit/schemacop/v2/validator_string_test.rb".freeze, "test/unit/schemacop/v2/validator_symbol_test.rb".freeze, "test/unit/schemacop/v3/all_of_node_test.rb".freeze, "test/unit/schemacop/v3/any_of_node_test.rb".freeze, "test/unit/schemacop/v3/array_node_test.rb".freeze, "test/unit/schemacop/v3/boolean_node_test.rb".freeze, "test/unit/schemacop/v3/global_context_test.rb".freeze, "test/unit/schemacop/v3/hash_node_test.rb".freeze, "test/unit/schemacop/v3/integer_node_test.rb".freeze, "test/unit/schemacop/v3/is_not_node_test.rb".freeze, "test/unit/schemacop/v3/node_test.rb".freeze, "test/unit/schemacop/v3/number_node_test.rb".freeze, "test/unit/schemacop/v3/object_node_test.rb".freeze, "test/unit/schemacop/v3/one_of_node_test.rb".freeze, "test/unit/schemacop/v3/reference_node_test.rb".freeze, "test/unit/schemacop/v3/string_node_test.rb".freeze, "test/unit/schemacop/v3/symbol_node_test.rb".freeze]
13
13
  s.homepage = "https://github.com/sitrox/schemacop".freeze
14
14
  s.licenses = ["MIT".freeze]
15
- s.rubygems_version = "3.2.15".freeze
15
+ s.rubygems_version = "3.0.3".freeze
16
16
  s.summary = "Schemacop validates ruby structures consisting of nested hashes and arrays against simple schema definitions.".freeze
17
17
  s.test_files = ["test/lib/test_helper.rb".freeze, "test/schemas/nested/group.rb".freeze, "test/schemas/user.rb".freeze, "test/unit/schemacop/v2/casting_test.rb".freeze, "test/unit/schemacop/v2/collector_test.rb".freeze, "test/unit/schemacop/v2/custom_check_test.rb".freeze, "test/unit/schemacop/v2/custom_if_test.rb".freeze, "test/unit/schemacop/v2/defaults_test.rb".freeze, "test/unit/schemacop/v2/empty_test.rb".freeze, "test/unit/schemacop/v2/nil_dis_allow_test.rb".freeze, "test/unit/schemacop/v2/node_resolver_test.rb".freeze, "test/unit/schemacop/v2/short_forms_test.rb".freeze, "test/unit/schemacop/v2/types_test.rb".freeze, "test/unit/schemacop/v2/validator_array_test.rb".freeze, "test/unit/schemacop/v2/validator_boolean_test.rb".freeze, "test/unit/schemacop/v2/validator_float_test.rb".freeze, "test/unit/schemacop/v2/validator_hash_test.rb".freeze, "test/unit/schemacop/v2/validator_integer_test.rb".freeze, "test/unit/schemacop/v2/validator_nil_test.rb".freeze, "test/unit/schemacop/v2/validator_number_test.rb".freeze, "test/unit/schemacop/v2/validator_object_test.rb".freeze, "test/unit/schemacop/v2/validator_string_test.rb".freeze, "test/unit/schemacop/v2/validator_symbol_test.rb".freeze, "test/unit/schemacop/v3/all_of_node_test.rb".freeze, "test/unit/schemacop/v3/any_of_node_test.rb".freeze, "test/unit/schemacop/v3/array_node_test.rb".freeze, "test/unit/schemacop/v3/boolean_node_test.rb".freeze, "test/unit/schemacop/v3/global_context_test.rb".freeze, "test/unit/schemacop/v3/hash_node_test.rb".freeze, "test/unit/schemacop/v3/integer_node_test.rb".freeze, "test/unit/schemacop/v3/is_not_node_test.rb".freeze, "test/unit/schemacop/v3/node_test.rb".freeze, "test/unit/schemacop/v3/number_node_test.rb".freeze, "test/unit/schemacop/v3/object_node_test.rb".freeze, "test/unit/schemacop/v3/one_of_node_test.rb".freeze, "test/unit/schemacop/v3/reference_node_test.rb".freeze, "test/unit/schemacop/v3/string_node_test.rb".freeze, "test/unit/schemacop/v3/symbol_node_test.rb".freeze]
18
18
 
19
19
  if s.respond_to? :specification_version then
20
20
  s.specification_version = 4
21
- end
22
21
 
23
- if s.respond_to? :add_runtime_dependency then
24
- s.add_runtime_dependency(%q<activesupport>.freeze, [">= 4.0"])
25
- s.add_runtime_dependency(%q<ruby2_keywords>.freeze, ["= 0.0.4"])
26
- s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
27
- s.add_development_dependency(%q<rake>.freeze, [">= 0"])
28
- s.add_development_dependency(%q<minitest>.freeze, [">= 0"])
29
- s.add_development_dependency(%q<minitest-reporters>.freeze, [">= 0"])
30
- s.add_development_dependency(%q<colorize>.freeze, [">= 0"])
31
- s.add_development_dependency(%q<rubocop>.freeze, ["= 1.24.1"])
32
- s.add_development_dependency(%q<pry>.freeze, [">= 0"])
33
- s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
34
- s.add_development_dependency(%q<simplecov>.freeze, ["= 0.21.2"])
22
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
23
+ s.add_runtime_dependency(%q<activesupport>.freeze, [">= 4.0"])
24
+ s.add_runtime_dependency(%q<ruby2_keywords>.freeze, ["= 0.0.4"])
25
+ s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
26
+ s.add_development_dependency(%q<rake>.freeze, [">= 0"])
27
+ s.add_development_dependency(%q<minitest>.freeze, [">= 0"])
28
+ s.add_development_dependency(%q<minitest-reporters>.freeze, [">= 0"])
29
+ s.add_development_dependency(%q<colorize>.freeze, [">= 0"])
30
+ s.add_development_dependency(%q<rubocop>.freeze, ["= 1.24.1"])
31
+ s.add_development_dependency(%q<pry>.freeze, [">= 0"])
32
+ s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
33
+ s.add_development_dependency(%q<simplecov>.freeze, ["= 0.21.2"])
34
+ else
35
+ s.add_dependency(%q<activesupport>.freeze, [">= 4.0"])
36
+ s.add_dependency(%q<ruby2_keywords>.freeze, ["= 0.0.4"])
37
+ s.add_dependency(%q<bundler>.freeze, [">= 0"])
38
+ s.add_dependency(%q<rake>.freeze, [">= 0"])
39
+ s.add_dependency(%q<minitest>.freeze, [">= 0"])
40
+ s.add_dependency(%q<minitest-reporters>.freeze, [">= 0"])
41
+ s.add_dependency(%q<colorize>.freeze, [">= 0"])
42
+ s.add_dependency(%q<rubocop>.freeze, ["= 1.24.1"])
43
+ s.add_dependency(%q<pry>.freeze, [">= 0"])
44
+ s.add_dependency(%q<byebug>.freeze, [">= 0"])
45
+ s.add_dependency(%q<simplecov>.freeze, ["= 0.21.2"])
46
+ end
35
47
  else
36
48
  s.add_dependency(%q<activesupport>.freeze, [">= 4.0"])
37
49
  s.add_dependency(%q<ruby2_keywords>.freeze, ["= 0.0.4"])
@@ -125,9 +125,17 @@ class V3Test < SchemacopTest
125
125
  if match
126
126
  actual_errors.delete(match)
127
127
  else
128
- assert match,
129
- "Did not find error #{expected_error.inspect} in path #{path}, errors: " \
130
- + result.messages_by_path[path].inspect
128
+ assert match, <<~ERROR.strip
129
+ Errors mismatch in path #{path}:
130
+
131
+ Expected
132
+ --------
133
+ #{expected_error.blue}
134
+
135
+ #{'Actual'.red}
136
+ #{'------'.red}
137
+ #{result.messages_by_path[path].join("\n\n").green}
138
+ ERROR
131
139
  end
132
140
  end
133
141
  end
@@ -13,10 +13,20 @@ module Schemacop
13
13
  assert_validation('12')
14
14
  assert_validation('1234')
15
15
  assert_validation('1') do
16
- error '/', 'Does not match all allOf conditions.'
16
+ error '/', <<~PLAIN.strip
17
+ Matches 1 schemas but should match all of them:
18
+ - Schema 1:
19
+ - /: String is 1 characters long but must be at least 2.
20
+ - Schema 2: Matches
21
+ PLAIN
17
22
  end
18
23
  assert_validation('12345') do
19
- error '/', 'Does not match all allOf conditions.'
24
+ error '/', <<~PLAIN.strip
25
+ Matches 1 schemas but should match all of them:
26
+ - Schema 1: Matches
27
+ - Schema 2:
28
+ - /: String is 5 characters long but must be at most 4.
29
+ PLAIN
20
30
  end
21
31
  end
22
32
 
@@ -31,16 +41,37 @@ module Schemacop
31
41
  assert_validation(4)
32
42
 
33
43
  assert_validation(5) do
34
- error '/', 'Does not match all allOf conditions.'
44
+ error '/', <<~PLAIN.strip
45
+ Matches 1 schemas but should match all of them:
46
+ - Schema 1: Matches
47
+ - Schema 2:
48
+ - /: Value must have a maximum of 4.
49
+ PLAIN
35
50
  end
36
51
  assert_validation(1) do
37
- error '/', 'Does not match all allOf conditions.'
52
+ error '/', <<~PLAIN.strip
53
+ Matches 1 schemas but should match all of them:
54
+ - Schema 1:
55
+ - /: Value must have a minimum of 2.
56
+ - Schema 2: Matches
57
+ PLAIN
38
58
  end
39
59
  assert_validation({}) do
40
- error '/', 'Does not match all allOf conditions.'
60
+ error '/', <<~PLAIN.strip
61
+ Matches 0 schemas but should match all of them:
62
+ - Schema 1:
63
+ - /: Invalid type, got type "Hash", expected "integer".
64
+ - Schema 2:
65
+ - /: Invalid type, got type "Hash", expected "integer".
66
+ PLAIN
41
67
  end
42
68
  assert_validation(42) do
43
- error '/', 'Does not match all allOf conditions.'
69
+ error '/', <<~PLAIN.strip
70
+ Matches 1 schemas but should match all of them:
71
+ - Schema 1: Matches
72
+ - Schema 2:
73
+ - /: Value must have a maximum of 4.
74
+ PLAIN
44
75
  end
45
76
  end
46
77
 
@@ -62,10 +93,27 @@ module Schemacop
62
93
 
63
94
  assert_validation(foo: 2, bar: 7)
64
95
  assert_validation(foo: 5, bar: 7) do
65
- error '/', 'Does not match all allOf conditions.'
96
+ error '/', <<~PLAIN.strip
97
+ Matches 1 schemas but should match all of them:
98
+ - Schema 1:
99
+ - /foo: Matches 1 schemas but should match all of them:
100
+ - Schema 1: Matches
101
+ - Schema 2:
102
+ - /: Value must have a maximum of 4.
103
+ - Schema 2: Matches
104
+ PLAIN
66
105
  end
67
106
  assert_validation(foo: 5) do
68
- error '/', 'Does not match all allOf conditions.'
107
+ error '/', <<~PLAIN.strip
108
+ Matches 0 schemas but should match all of them:
109
+ - Schema 1:
110
+ - /foo: Matches 1 schemas but should match all of them:
111
+ - Schema 1: Matches
112
+ - Schema 2:
113
+ - /: Value must have a maximum of 4.
114
+ - Schema 2:
115
+ - /bar: Value must be given.
116
+ PLAIN
69
117
  end
70
118
  end
71
119
 
@@ -77,7 +125,11 @@ module Schemacop
77
125
  assert_validation(nil)
78
126
  assert_validation('1')
79
127
  assert_validation('Foo') do
80
- error '/', 'Does not match all allOf conditions.'
128
+ error '/', <<~PLAIN.strip
129
+ Matches 0 schemas but should match all of them:
130
+ - Schema 1:
131
+ - /: String does not match format "integer".
132
+ PLAIN
81
133
  end
82
134
 
83
135
  assert_cast('1', 1)
@@ -96,11 +148,23 @@ module Schemacop
96
148
  assert_validation('123')
97
149
 
98
150
  assert_validation('1') do
99
- error '/', 'Does not match all allOf conditions.'
151
+ error '/', <<~PLAIN.strip
152
+ Matches 2 schemas but should match all of them:
153
+ - Schema 1: Matches
154
+ - Schema 2:
155
+ - /: String is 1 characters long but must be at least 2.
156
+ - Schema 3: Matches
157
+ PLAIN
100
158
  end
101
159
 
102
160
  assert_validation('1234') do
103
- error '/', 'Does not match all allOf conditions.'
161
+ error '/', <<~PLAIN.strip
162
+ Matches 2 schemas but should match all of them:
163
+ - Schema 1: Matches
164
+ - Schema 2: Matches
165
+ - Schema 3:
166
+ - /: String is 4 characters long but must be at most 3.
167
+ PLAIN
104
168
  end
105
169
  assert_cast('42', 42)
106
170
  end
@@ -117,11 +181,23 @@ module Schemacop
117
181
  assert_validation('123')
118
182
 
119
183
  assert_validation('1') do
120
- error '/', 'Does not match all allOf conditions.'
184
+ error '/', <<~PLAIN.strip
185
+ Matches 2 schemas but should match all of them:
186
+ - Schema 1:
187
+ - /: String is 1 characters long but must be at least 2.
188
+ - Schema 2: Matches
189
+ - Schema 3: Matches
190
+ PLAIN
121
191
  end
122
192
 
123
193
  assert_validation('1234') do
124
- error '/', 'Does not match all allOf conditions.'
194
+ error '/', <<~PLAIN.strip
195
+ Matches 2 schemas but should match all of them:
196
+ - Schema 1: Matches
197
+ - Schema 2:
198
+ - /: String is 4 characters long but must be at most 3.
199
+ - Schema 3: Matches
200
+ PLAIN
125
201
  end
126
202
 
127
203
  assert_cast('42', 42)
@@ -154,10 +230,20 @@ module Schemacop
154
230
 
155
231
  assert_validation(nil)
156
232
  assert_validation('42') do
157
- error '/', 'Does not match all allOf conditions.'
233
+ error '/', <<~PLAIN.strip
234
+ Matches 1 schemas but should match all of them:
235
+ - Schema 1: Matches
236
+ - Schema 2:
237
+ - /: String does not match format "boolean".
238
+ PLAIN
158
239
  end
159
240
  assert_validation('true') do
160
- error '/', 'Does not match all allOf conditions.'
241
+ error '/', <<~PLAIN.strip
242
+ Matches 1 schemas but should match all of them:
243
+ - Schema 1:
244
+ - /: String does not match format "integer".
245
+ - Schema 2: Matches
246
+ PLAIN
161
247
  end
162
248
  end
163
249
 
@@ -13,10 +13,22 @@ module Schemacop
13
13
  assert_validation('string')
14
14
  assert_validation(42)
15
15
  assert_validation(42.1) do
16
- error '/', 'Does not match any anyOf condition.'
16
+ error '/', <<~PLAIN.strip
17
+ Matches 0 schemas but should match at least 1:
18
+ - Schema 1:
19
+ - /: Invalid type, got type "Float", expected "string".
20
+ - Schema 2:
21
+ - /: Invalid type, got type "Float", expected "integer".
22
+ PLAIN
17
23
  end
18
24
  assert_validation({}) do
19
- error '/', 'Does not match any anyOf condition.'
25
+ error '/', <<~PLAIN.strip
26
+ Matches 0 schemas but should match at least 1:
27
+ - Schema 1:
28
+ - /: Invalid type, got type "Hash", expected "string".
29
+ - Schema 2:
30
+ - /: Invalid type, got type "Hash", expected "integer".
31
+ PLAIN
20
32
  end
21
33
  end
22
34
 
@@ -34,10 +46,22 @@ module Schemacop
34
46
  end
35
47
 
36
48
  assert_validation(42.1) do
37
- error '/', 'Does not match any anyOf condition.'
49
+ error '/', <<~PLAIN.strip
50
+ Matches 0 schemas but should match at least 1:
51
+ - Schema 1:
52
+ - /: Invalid type, got type "Float", expected "string".
53
+ - Schema 2:
54
+ - /: Invalid type, got type "Float", expected "integer".
55
+ PLAIN
38
56
  end
39
57
  assert_validation({}) do
40
- error '/', 'Does not match any anyOf condition.'
58
+ error '/', <<~PLAIN.strip
59
+ Matches 0 schemas but should match at least 1:
60
+ - Schema 1:
61
+ - /: Invalid type, got type "Hash", expected "string".
62
+ - Schema 2:
63
+ - /: Invalid type, got type "Hash", expected "integer".
64
+ PLAIN
41
65
  end
42
66
  end
43
67
 
@@ -57,13 +81,36 @@ module Schemacop
57
81
  assert_validation(foo: 42)
58
82
  assert_validation(foo: 'str')
59
83
  assert_validation('string') do
60
- error '/', 'Does not match any anyOf condition.'
84
+ error '/', <<~PLAIN.strip
85
+ Matches 0 schemas but should match at least 1:
86
+ - Schema 1:
87
+ - /: Invalid type, got type "String", expected "object".
88
+ - Schema 2:
89
+ - /: Invalid type, got type "String", expected "integer".
90
+ PLAIN
61
91
  end
62
92
  assert_validation(bar: :baz) do
63
- error '/', 'Does not match any anyOf condition.'
93
+ error '/', <<~PLAIN.strip
94
+ Matches 0 schemas but should match at least 1:
95
+ - Schema 1:
96
+ - /foo: Value must be given.
97
+ - /: Obsolete property "bar".
98
+ - Schema 2:
99
+ - /: Invalid type, got type "Hash", expected "integer".
100
+ PLAIN
64
101
  end
65
102
  assert_validation(foo: :bar) do
66
- error '/', 'Does not match any anyOf condition.'
103
+ error '/', <<~PLAIN.strip
104
+ Matches 0 schemas but should match at least 1:
105
+ - Schema 1:
106
+ - /foo: Matches 0 schemas but should match at least 1:
107
+ - Schema 1:
108
+ - /: Invalid type, got type "Symbol", expected "integer".
109
+ - Schema 2:
110
+ - /: Invalid type, got type "Symbol", expected "string".
111
+ - Schema 2:
112
+ - /: Invalid type, got type "Hash", expected "integer".
113
+ PLAIN
67
114
  end
68
115
  end
69
116
 
@@ -109,13 +156,109 @@ module Schemacop
109
156
  assert_validation(Time.now)
110
157
 
111
158
  assert_validation('1990-01-13 12') do
112
- error '/', 'Does not match any anyOf condition.'
159
+ error '/', <<~PLAIN.strip
160
+ Matches 0 schemas but should match at least 1:
161
+ - Schema 1:
162
+ - /: Matches 0 schemas but should match all of them:
163
+ - Schema 1:
164
+ - /: Invalid type, got type "String", expected "object".
165
+ - Schema 2:
166
+ - /: Matches 0 schemas but should match at least 1:
167
+ - Schema 1:
168
+ - /: Invalid type, got type "String", expected "Date".
169
+ - Schema 2:
170
+ - /: Invalid type, got type "String", expected "Time".
171
+ - Schema 3:
172
+ - /: Invalid type, got type "String", expected "array".
173
+ - Schema 4:
174
+ - /: Invalid type, got type "String", expected "boolean".
175
+ - Schema 5:
176
+ - /: Invalid type, got type "String", expected "integer".
177
+ - Schema 6:
178
+ - /: Invalid type, got type "String", expected "big_decimal" or "float" or "integer" or "rational".
179
+ - Schema 7:
180
+ - /: Invalid type, got type "String", expected "object".
181
+ - Schema 8:
182
+ - /: Matches 0 schemas but should match exactly 1:
183
+ - Schema 1:
184
+ - /: Invalid type, got type "String", expected "object".
185
+ - Schema 2:
186
+ - /: Invalid type, got type "String", expected "object".
187
+ - Schema 9:
188
+ - /: String does not match format "date".
189
+ - Schema 10:
190
+ - /: String is 13 characters long but must be at most 2.
191
+ PLAIN
113
192
  end
114
193
  assert_validation(a: 'a hello z') do
115
- error '/', 'Does not match any anyOf condition.'
194
+ error '/', <<~PLAIN.strip
195
+ Matches 0 schemas but should match at least 1:
196
+ - Schema 1:
197
+ - /: Matches 0 schemas but should match all of them:
198
+ - Schema 1:
199
+ - /foo: Value must be given.
200
+ - /: Obsolete property "a".
201
+ - Schema 2:
202
+ - /: Matches 0 schemas but should match at least 1:
203
+ - Schema 1:
204
+ - /: Invalid type, got type "Hash", expected "Date".
205
+ - Schema 2:
206
+ - /: Invalid type, got type "Hash", expected "Time".
207
+ - Schema 3:
208
+ - /: Invalid type, got type "Hash", expected "array".
209
+ - Schema 4:
210
+ - /: Invalid type, got type "Hash", expected "boolean".
211
+ - Schema 5:
212
+ - /: Invalid type, got type "Hash", expected "integer".
213
+ - Schema 6:
214
+ - /: Invalid type, got type "Hash", expected "big_decimal" or "float" or "integer" or "rational".
215
+ - Schema 7:
216
+ - /bar: Value must be given.
217
+ - /: Obsolete property "a".
218
+ - Schema 8:
219
+ - /: Matches 2 schemas but should match exactly 1:
220
+ - Schema 1: Matches
221
+ - Schema 2: Matches
222
+ - Schema 9:
223
+ - /: Invalid type, got type "Hash", expected "string".
224
+ - Schema 10:
225
+ - /: Invalid type, got type "Hash", expected "string".
226
+ PLAIN
116
227
  end
117
228
  assert_validation(Object.new) do
118
- error '/', 'Does not match any anyOf condition.'
229
+ error '/', <<~PLAIN.strip
230
+ Matches 0 schemas but should match at least 1:
231
+ - Schema 1:
232
+ - /: Matches 0 schemas but should match all of them:
233
+ - Schema 1:
234
+ - /: Invalid type, got type "Object", expected "object".
235
+ - Schema 2:
236
+ - /: Matches 0 schemas but should match at least 1:
237
+ - Schema 1:
238
+ - /: Invalid type, got type "Object", expected "Date".
239
+ - Schema 2:
240
+ - /: Invalid type, got type "Object", expected "Time".
241
+ - Schema 3:
242
+ - /: Invalid type, got type "Object", expected "array".
243
+ - Schema 4:
244
+ - /: Invalid type, got type "Object", expected "boolean".
245
+ - Schema 5:
246
+ - /: Invalid type, got type "Object", expected "integer".
247
+ - Schema 6:
248
+ - /: Invalid type, got type "Object", expected "big_decimal" or "float" or "integer" or "rational".
249
+ - Schema 7:
250
+ - /: Invalid type, got type "Object", expected "object".
251
+ - Schema 8:
252
+ - /: Matches 0 schemas but should match exactly 1:
253
+ - Schema 1:
254
+ - /: Invalid type, got type "Object", expected "object".
255
+ - Schema 2:
256
+ - /: Invalid type, got type "Object", expected "object".
257
+ - Schema 9:
258
+ - /: Invalid type, got type "Object", expected "string".
259
+ - Schema 10:
260
+ - /: Invalid type, got type "Object", expected "string".
261
+ PLAIN
119
262
  end
120
263
  end
121
264
  end
@@ -153,7 +296,13 @@ module Schemacop
153
296
  assert_validation(foo: { baz: 'Baz' })
154
297
 
155
298
  assert_validation(foo: { xyz: 'Baz' }) do
156
- error '/foo', 'Does not match any anyOf condition.'
299
+ error '/foo', <<~PLAIN.strip
300
+ Matches 0 schemas but should match at least 1:
301
+ - Schema 1:
302
+ - /: Obsolete property "xyz".
303
+ - Schema 2:
304
+ - /: Obsolete property "xyz".
305
+ PLAIN
157
306
  end
158
307
 
159
308
  assert_cast(
@@ -393,10 +393,22 @@ module Schemacop
393
393
  assert_validation(['foo', 42])
394
394
  assert_validation(['foo', 42, '1990-01-01'])
395
395
  assert_validation(['foo', 42, '1990-01-01', 42]) do
396
- error '/[3]', 'Matches 0 definitions but should match exactly 1.'
396
+ error '/[3]', <<~PLAIN.strip
397
+ Matches 0 schemas but should match exactly 1:
398
+ - Schema 1:
399
+ - /: Invalid type, got type "Integer", expected "string".
400
+ - Schema 2:
401
+ - /: Invalid type, got type "Integer", expected "string".
402
+ PLAIN
397
403
  end
398
404
  assert_validation(['foo', 42, '1990-01-01', 'foo']) do
399
- error '/[3]', 'Matches 0 definitions but should match exactly 1.'
405
+ error '/[3]', <<~PLAIN.strip
406
+ Matches 0 schemas but should match exactly 1:
407
+ - Schema 1:
408
+ - /: String does not match format "date".
409
+ - Schema 2:
410
+ - /: String does not match format "integer".
411
+ PLAIN
400
412
  end
401
413
 
402
414
  assert_cast(['foo', 42], ['foo', 42])
@@ -188,7 +188,13 @@ module Schemacop
188
188
  assert_cast('False', false)
189
189
 
190
190
  assert_validation('5') do
191
- error '/', 'Matches 0 definitions but should match exactly 1.'
191
+ error '/', <<~PLAIN.strip
192
+ Matches 0 schemas but should match exactly 1:
193
+ - Schema 1:
194
+ - /: Invalid type, got type "String", expected "boolean".
195
+ - Schema 2:
196
+ - /: String does not match format "boolean".
197
+ PLAIN
192
198
  end
193
199
 
194
200
  # Nil can be validated, as it's not required
@@ -217,11 +223,23 @@ module Schemacop
217
223
  assert_cast('FALSE', false)
218
224
 
219
225
  assert_validation('4') do
220
- error '/', 'Matches 0 definitions but should match exactly 1.'
226
+ error '/', <<~PLAIN.strip
227
+ Matches 0 schemas but should match exactly 1:
228
+ - Schema 1:
229
+ - /: Invalid type, got type "String", expected "boolean".
230
+ - Schema 2:
231
+ - /: String does not match format "boolean".
232
+ PLAIN
221
233
  end
222
234
 
223
235
  assert_validation('foo') do
224
- error '/', 'Matches 0 definitions but should match exactly 1.'
236
+ error '/', <<~PLAIN.strip
237
+ Matches 0 schemas but should match exactly 1:
238
+ - Schema 1:
239
+ - /: Invalid type, got type "String", expected "boolean".
240
+ - Schema 2:
241
+ - /: String does not match format "boolean".
242
+ PLAIN
225
243
  end
226
244
 
227
245
  assert_validation(nil) do
@@ -354,7 +354,12 @@ module Schemacop
354
354
  assert_validation(str: '1234')
355
355
  assert_validation(str: '12345')
356
356
  assert_validation(str: '0') do
357
- error '/str', 'Does not match all allOf conditions.'
357
+ error '/str', <<~PLAIN.strip
358
+ Matches 1 schemas but should match all of them:
359
+ - Schema 1:
360
+ - /: String is 1 characters long but must be at least 3.
361
+ - Schema 2: Matches
362
+ PLAIN
358
363
  end
359
364
  end
360
365
 
@@ -372,7 +377,11 @@ module Schemacop
372
377
  error '/str', 'Value must be given.'
373
378
  end
374
379
  assert_validation(str: '1234') do
375
- error '/str', 'Matches 2 definitions but should match exactly 1.'
380
+ error '/str', <<~PLAIN.strip
381
+ Matches 2 schemas but should match exactly 1:
382
+ - Schema 1: Matches
383
+ - Schema 2: Matches
384
+ PLAIN
376
385
  end
377
386
  end
378
387
 
@@ -389,7 +398,11 @@ module Schemacop
389
398
  assert_validation(str: nil)
390
399
  assert_validation({})
391
400
  assert_validation(str: '1234') do
392
- error '/str', 'Matches 2 definitions but should match exactly 1.'
401
+ error '/str', <<~PLAIN.strip
402
+ Matches 2 schemas but should match exactly 1:
403
+ - Schema 1: Matches
404
+ - Schema 2: Matches
405
+ PLAIN
393
406
  end
394
407
  end
395
408
 
@@ -404,7 +417,13 @@ module Schemacop
404
417
  assert_validation(str_or_int: 'Hello World')
405
418
  assert_validation(str_or_int: 42)
406
419
  assert_validation(str_or_int: :foo) do
407
- error '/str_or_int', 'Does not match any anyOf condition.'
420
+ error '/str_or_int', <<~PLAIN.strip
421
+ Matches 0 schemas but should match at least 1:
422
+ - Schema 1:
423
+ - /: Invalid type, got type "Symbol", expected "string".
424
+ - Schema 2:
425
+ - /: Invalid type, got type "Symbol", expected "integer".
426
+ PLAIN
408
427
  end
409
428
  end
410
429
 
@@ -421,7 +440,13 @@ module Schemacop
421
440
  assert_validation(str_or_int: nil)
422
441
  assert_validation({})
423
442
  assert_validation(str_or_int: :foo) do
424
- error '/str_or_int', 'Does not match any anyOf condition.'
443
+ error '/str_or_int', <<~PLAIN.strip
444
+ Matches 0 schemas but should match at least 1:
445
+ - Schema 1:
446
+ - /: Invalid type, got type "Symbol", expected "string".
447
+ - Schema 2:
448
+ - /: Invalid type, got type "Symbol", expected "integer".
449
+ PLAIN
425
450
  end
426
451
  end
427
452
 
@@ -659,7 +684,13 @@ module Schemacop
659
684
  assert_validation(foo: '1', bar: '2')
660
685
  assert_validation(foo: '1', bar: '2', baz: 3)
661
686
  assert_validation(foo: '1', bar: '2', baz: 3, qux: [1, 2]) do
662
- error '/qux', 'Does not match any anyOf condition.'
687
+ error '/qux', <<~PLAIN.strip
688
+ Matches 0 schemas but should match at least 1:
689
+ - Schema 1:
690
+ - /: Invalid type, got type "Array", expected "string".
691
+ - Schema 2:
692
+ - /: Invalid type, got type "Array", expected "integer".
693
+ PLAIN
663
694
  end
664
695
 
665
696
  assert_cast({ foo: '1', bar: '2' }, { foo: 1, bar: '2' }.with_indifferent_access)
@@ -700,7 +731,15 @@ module Schemacop
700
731
  assert_validation(foo: '1', bar: '2')
701
732
  assert_validation(foo: '1', bar: '2', baz: 3)
702
733
  assert_validation(foo: '1', bar: '2', baz: 3, qux: [1, 2]) do
703
- error '/qux', 'Does not match any anyOf condition.'
734
+ error '/qux', <<~PLAIN.strip
735
+ Matches 0 schemas but should match at least 1:
736
+ - Schema 1:
737
+ - /: Invalid type, got type "Array", expected "string".
738
+ - Schema 2:
739
+ - /: Invalid type, got type "Array", expected "string".
740
+ - Schema 3:
741
+ - /: Invalid type, got type "Array", expected "integer".
742
+ PLAIN
704
743
  end
705
744
 
706
745
  assert_cast({ foo: '1', bar: '2' }, { foo: 1, bar: 2 }.with_indifferent_access)
@@ -348,7 +348,13 @@ module Schemacop
348
348
  assert_cast('', nil)
349
349
 
350
350
  assert_validation('true') do
351
- error '/', 'Matches 0 definitions but should match exactly 1.'
351
+ error '/', <<~PLAIN.strip
352
+ Matches 0 schemas but should match exactly 1:
353
+ - Schema 1:
354
+ - /: Invalid type, got type "String", expected "integer".
355
+ - Schema 2:
356
+ - /: String does not match format "integer".
357
+ PLAIN
352
358
  end
353
359
  end
354
360
 
@@ -367,7 +373,13 @@ module Schemacop
367
373
  end
368
374
 
369
375
  assert_validation('true') do
370
- error '/', 'Matches 0 definitions but should match exactly 1.'
376
+ error '/', <<~PLAIN.strip
377
+ Matches 0 schemas but should match exactly 1:
378
+ - Schema 1:
379
+ - /: Invalid type, got type "String", expected "integer".
380
+ - Schema 2:
381
+ - /: String does not match format "integer".
382
+ PLAIN
371
383
  end
372
384
  end
373
385
  end
@@ -99,7 +99,13 @@ module Schemacop
99
99
 
100
100
  assert_validation('5')
101
101
  assert_validation('5.3') do
102
- error '/', 'Matches 0 definitions but should match exactly 1.'
102
+ error '/', <<~PLAIN.strip
103
+ Matches 0 schemas but should match exactly 1:
104
+ - Schema 1:
105
+ - /: Invalid type, got type "String", expected "integer".
106
+ - Schema 2:
107
+ - /: String does not match format "integer".
108
+ PLAIN
103
109
  end
104
110
 
105
111
  assert_cast(5, 5)
@@ -125,13 +131,31 @@ module Schemacop
125
131
  assert_validation([nil])
126
132
  assert_validation([5, 5.3, '42.0', '42.42'])
127
133
  assert_validation([5, 5.3, '42.0', '42.42', 'bar']) do
128
- error '/[4]', 'Matches 0 definitions but should match exactly 1.'
134
+ error '/[4]', <<~PLAIN.strip
135
+ Matches 0 schemas but should match exactly 1:
136
+ - Schema 1:
137
+ - /: Invalid type, got type "String", expected "big_decimal" or "float" or "integer" or "rational".
138
+ - Schema 2:
139
+ - /: String does not match format "number".
140
+ PLAIN
129
141
  end
130
142
  assert_validation([2]) do
131
- error '/[0]', 'Matches 0 definitions but should match exactly 1.'
143
+ error '/[0]', <<~PLAIN.strip
144
+ Matches 0 schemas but should match exactly 1:
145
+ - Schema 1:
146
+ - /: Value must have a minimum of 3.
147
+ - Schema 2:
148
+ - /: Invalid type, got type "Integer", expected "string".
149
+ PLAIN
132
150
  end
133
151
  assert_validation(['2']) do
134
- error '/[0]', 'Matches 0 definitions but should match exactly 1.'
152
+ error '/[0]', <<~PLAIN.strip
153
+ Matches 0 schemas but should match exactly 1:
154
+ - Schema 1:
155
+ - /: Invalid type, got type "String", expected "big_decimal" or "float" or "integer" or "rational".
156
+ - Schema 2:
157
+ - /: Value must have a minimum of 3.
158
+ PLAIN
135
159
  end
136
160
 
137
161
  assert_cast(['3'], [3])
@@ -323,19 +323,43 @@ module Schemacop
323
323
  assert_validation('0.5')
324
324
 
325
325
  assert_validation('true') do
326
- error '/', 'Matches 0 definitions but should match exactly 1.'
326
+ error '/', <<~PLAIN.strip
327
+ Matches 0 schemas but should match exactly 1:
328
+ - Schema 1:
329
+ - /: Invalid type, got type "String", expected "big_decimal" or "float" or "integer" or "rational".
330
+ - Schema 2:
331
+ - /: String does not match format "number".
332
+ PLAIN
327
333
  end
328
334
 
329
335
  assert_validation('51') do
330
- error '/', 'Matches 0 definitions but should match exactly 1.'
336
+ error '/', <<~PLAIN.strip
337
+ Matches 0 schemas but should match exactly 1:
338
+ - Schema 1:
339
+ - /: Invalid type, got type "String", expected "big_decimal" or "float" or "integer" or "rational".
340
+ - Schema 2:
341
+ - /: Value must have a maximum of 50/1.
342
+ PLAIN
331
343
  end
332
344
 
333
345
  assert_validation('-2') do
334
- error '/', 'Matches 0 definitions but should match exactly 1.'
346
+ error '/', <<~PLAIN.strip
347
+ Matches 0 schemas but should match exactly 1:
348
+ - Schema 1:
349
+ - /: Invalid type, got type "String", expected "big_decimal" or "float" or "integer" or "rational".
350
+ - Schema 2:
351
+ - /: Value must have a minimum of 0.0.
352
+ PLAIN
335
353
  end
336
354
 
337
355
  assert_validation('3.1415') do
338
- error '/', 'Matches 0 definitions but should match exactly 1.'
356
+ error '/', <<~PLAIN.strip
357
+ Matches 0 schemas but should match exactly 1:
358
+ - Schema 1:
359
+ - /: Invalid type, got type "String", expected "big_decimal" or "float" or "integer" or "rational".
360
+ - Schema 2:
361
+ - /: Value must be a multiple of 0.5.
362
+ PLAIN
339
363
  end
340
364
  end
341
365
  end
@@ -3,6 +3,31 @@ require 'test_helper'
3
3
  module Schemacop
4
4
  module V3
5
5
  class OneOfNodeTest < V3Test
6
+ def test_todo
7
+ schema(:one_of) do
8
+ hsh do
9
+ str! :name
10
+ str! :email
11
+ end
12
+ hsh do
13
+ int! :id
14
+ end
15
+ end
16
+
17
+ assert_validation(name: 'John', email: 'john@doe.com')
18
+ assert_validation(id: 42)
19
+ assert_validation(id: 42, name: 'John') do
20
+ error '/', <<~PLAIN.strip
21
+ Matches 0 schemas but should match exactly 1:
22
+ - Schema 1:
23
+ - /email: Value must be given.
24
+ - /: Obsolete property "id".
25
+ - Schema 2:
26
+ - /: Obsolete property "name".
27
+ PLAIN
28
+ end
29
+ end
30
+
6
31
  def test_optional
7
32
  schema :one_of do
8
33
  num multiple_of: 2
@@ -15,13 +40,35 @@ module Schemacop
15
40
  assert_validation(9)
16
41
  assert_validation('foo')
17
42
  assert_validation(12) do
18
- error '/', 'Matches 2 definitions but should match exactly 1.'
43
+ error '/', <<~PLAIN.strip
44
+ Matches 2 schemas but should match exactly 1:
45
+ - Schema 1: Matches
46
+ - Schema 2: Matches
47
+ - Schema 3:
48
+ - /: Invalid type, got type "Integer", expected "string".
49
+ PLAIN
19
50
  end
20
51
  assert_validation(1) do
21
- error '/', 'Matches 0 definitions but should match exactly 1.'
52
+ error '/', <<~PLAIN.strip
53
+ Matches 0 schemas but should match exactly 1:
54
+ - Schema 1:
55
+ - /: Value must be a multiple of 2.
56
+ - Schema 2:
57
+ - /: Value must be a multiple of 3.
58
+ - Schema 3:
59
+ - /: Invalid type, got type "Integer", expected "string".
60
+ PLAIN
22
61
  end
23
62
  assert_validation(:foo) do
24
- error '/', 'Matches 0 definitions but should match exactly 1.'
63
+ error '/', <<~PLAIN.strip
64
+ Matches 0 schemas but should match exactly 1:
65
+ - Schema 1:
66
+ - /: Invalid type, got type "Symbol", expected "big_decimal" or "float" or "integer" or "rational".
67
+ - Schema 2:
68
+ - /: Invalid type, got type "Symbol", expected "big_decimal" or "float" or "integer" or "rational".
69
+ - Schema 3:
70
+ - /: Invalid type, got type "Symbol", expected "string".
71
+ PLAIN
25
72
  end
26
73
  end
27
74
 
@@ -57,10 +104,22 @@ module Schemacop
57
104
  assert_validation(foo: 9)
58
105
  assert_validation(foo: 7)
59
106
  assert_validation(foo: 14) do
60
- error '/', 'Matches 2 definitions but should match exactly 1.'
107
+ error '/', <<~PLAIN.strip
108
+ Matches 2 schemas but should match exactly 1:
109
+ - Schema 1: Matches
110
+ - Schema 2: Matches
111
+ PLAIN
61
112
  end
62
113
  assert_validation(foo: 12) do
63
- error '/', 'Matches 0 definitions but should match exactly 1.'
114
+ error '/', <<~PLAIN.strip
115
+ Matches 0 schemas but should match exactly 1:
116
+ - Schema 1:
117
+ - /foo: Matches 2 schemas but should match exactly 1:
118
+ - Schema 1: Matches
119
+ - Schema 2: Matches
120
+ - Schema 2:
121
+ - /foo: Value must be a multiple of 7.
122
+ PLAIN
64
123
  end
65
124
 
66
125
  assert_json(
@@ -122,7 +181,13 @@ module Schemacop
122
181
  assert_validation(foo: { baz: 'Baz' })
123
182
 
124
183
  assert_validation(foo: { xyz: 'Baz' }) do
125
- error '/foo', 'Matches 0 definitions but should match exactly 1.'
184
+ error '/foo', <<~PLAIN.strip
185
+ Matches 0 schemas but should match exactly 1:
186
+ - Schema 1:
187
+ - /: Obsolete property "xyz".
188
+ - Schema 2:
189
+ - /: Obsolete property "xyz".
190
+ PLAIN
126
191
  end
127
192
 
128
193
  assert_cast(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schemacop
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.19
4
+ version: 3.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sitrox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-19 00:00:00.000000000 Z
11
+ date: 2022-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport