json_schema 0.17.1 → 0.17.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/json_schema/attributes.rb +5 -7
- data/lib/json_schema/validator.rb +7 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 635babaf9176db9c16a7564e0cdb8804ba209201
|
4
|
+
data.tar.gz: c866943726dbe55237d5c7931793d5ecf149945a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5caf545cbf4684cad41d64fc889d5c167f2e4f3980b91014a7367fef4f070a4fd5b77b138f80f12f34b3d62fbae11bd0890a67d1a490228db59a4cccf9b1a263
|
7
|
+
data.tar.gz: ff16d212597fbeab145f40023052e1e792014cd78c7ebafc65bd75af7c505879622a65cbbe037037ff287ceb3274288da603f6afcf21c79eb5628a4dd398ee8f
|
@@ -25,23 +25,21 @@ module JsonSchema
|
|
25
25
|
def attr_copyable(attr, options = {})
|
26
26
|
attr_accessor(attr)
|
27
27
|
|
28
|
+
ref = :"@#{attr}"
|
28
29
|
# Usually the default being assigned here is nil.
|
29
|
-
self.copyable_attrs[
|
30
|
+
self.copyable_attrs[ref] = options[:default]
|
30
31
|
|
31
32
|
if default = options[:default]
|
32
33
|
# remove the reader already created by attr_accessor
|
33
34
|
remove_method(attr)
|
34
35
|
|
36
|
+
need_dup = [Array, Hash, Set].include?(default.class)
|
35
37
|
define_method(attr) do
|
36
|
-
val = instance_variable_get(
|
38
|
+
val = instance_variable_get(ref)
|
37
39
|
if !val.nil?
|
38
40
|
val
|
39
41
|
else
|
40
|
-
|
41
|
-
default.dup
|
42
|
-
else
|
43
|
-
default
|
44
|
-
end
|
42
|
+
need_dup ? default.class.new : default
|
45
43
|
end
|
46
44
|
end
|
47
45
|
end
|
@@ -172,22 +172,17 @@ module JsonSchema
|
|
172
172
|
def validate_any_of(schema, data, errors, path)
|
173
173
|
return true if schema.any_of.empty?
|
174
174
|
|
175
|
-
sub_errors =
|
176
|
-
|
177
|
-
subschemata_validity = schema.any_of.map do |subschema|
|
175
|
+
sub_errors = schema.any_of.map do |subschema|
|
178
176
|
current_sub_errors = []
|
179
|
-
|
180
|
-
|
177
|
+
return true if validate_data(subschema, data, current_sub_errors, path)
|
178
|
+
current_sub_errors
|
181
179
|
end
|
182
180
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
sub_errors: sub_errors, data: data)
|
187
|
-
return false
|
188
|
-
end
|
181
|
+
message = %{No subschema in "anyOf" matched.}
|
182
|
+
errors << ValidationError.new(schema, path, message, :any_of_failed,
|
183
|
+
sub_errors: sub_errors, data: data)
|
189
184
|
|
190
|
-
|
185
|
+
false
|
191
186
|
end
|
192
187
|
|
193
188
|
def validate_dependencies(schema, data, errors, path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ecma-re-validator
|