json-schema 2.1.5 → 2.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,7 @@ From the git repo:
22
22
 
23
23
  <pre>
24
24
  $ gem build json-schema.gemspec
25
- $ gem install json-schema-2.1.5.gem
25
+ $ gem install json-schema-2.1.6.gem
26
26
  </pre>
27
27
 
28
28
 
@@ -6,7 +6,7 @@ module JSON
6
6
  current_schema.schema['dependencies'].each do |property,dependency_value|
7
7
  if (data.has_key?(property.to_s) || data.has_key?(property.to_sym)) && dependency_value.is_a?(Array)
8
8
  dependency_value.each do |value|
9
- if !data.has_key?(value.to_s)
9
+ if !data.has_key?(value.to_s) && !data.has_key?(value.to_sym)
10
10
  message = "The property '#{build_fragment(fragments)}' has a property '#{property}' that depends on a missing property '#{value}'"
11
11
  validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
12
12
  end
@@ -10,18 +10,18 @@ module JSON
10
10
  !property_schema['readonly'] &&
11
11
  options[:insert_defaults]
12
12
  default = property_schema['default']
13
- data[property] = (default.is_a?(Hash) ? default.clone : default)
13
+ data[property.to_s] = (default.is_a?(Hash) ? default.clone : default)
14
14
  end
15
15
 
16
- if property_schema['required'] && !data.has_key?(property.to_s)
16
+ if property_schema['required'] && !data.has_key?(property.to_s) && !data.has_key?(property.to_sym)
17
17
  message = "The property '#{build_fragment(fragments)}' did not contain a required property of '#{property}'"
18
18
  validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
19
19
  end
20
20
 
21
21
  if data.has_key?(property.to_s) || data.has_key?(property.to_sym)
22
22
  schema = JSON::Schema.new(property_schema,current_schema.uri,validator)
23
- fragments << property
24
- schema.validate(data[property],fragments,processor,options)
23
+ fragments << property.to_s
24
+ schema.validate(data[property.to_s],fragments,processor,options)
25
25
  fragments.pop
26
26
  end
27
27
  end
@@ -10,13 +10,13 @@ module JSON
10
10
  !property_schema['readonly'] &&
11
11
  options[:insert_defaults]
12
12
  default = property_schema['default']
13
- data[property] = (default.is_a?(Hash) ? default.clone : default)
13
+ data[property.to_s] = (default.is_a?(Hash) ? default.clone : default)
14
14
  end
15
15
 
16
- if data.has_key?(property.to_s)
16
+ if data.has_key?(property.to_s) || data.has_key?(property.to_sym)
17
17
  schema = JSON::Schema.new(property_schema,current_schema.uri,validator)
18
- fragments << property
19
- schema.validate(data[property],fragments,processor,options)
18
+ fragments << property.to_s
19
+ schema.validate(data[property.to_s],fragments,processor,options)
20
20
  fragments.pop
21
21
  end
22
22
  end
@@ -34,5 +34,11 @@ class RubySchemaTest < Test::Unit::TestCase
34
34
  }
35
35
 
36
36
  assert(JSON::Validator.validate(schema, data))
37
+
38
+ data = {
39
+ a: false
40
+ }
41
+
42
+ assert(!JSON::Validator.validate(schema, data))
37
43
  end
38
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: