Sha256: 47ef647734c8ee54d7443802f1858a2e8126fa9b0b27e3b37bbdf87a71b5e32e
Contents?: true
Size: 1.25 KB
Versions: 13
Compression:
Stored size: 1.25 KB
Contents
module JSON class Schema class DependenciesAttribute < Attribute def self.validate(current_schema, data, fragments, validator, options = {}) if data.is_a?(Hash) current_schema.schema['dependencies'].each do |property,dependency_value| if data.has_key?(property) if dependency_value.is_a?(String) && !data.has_key?(dependency_value) message = "The property '#{build_fragment(fragments)}' has a property '#{property}' that depends on a missing property '#{dependency_value}'" raise ValidationError.new(message, fragments, current_schema) elsif dependency_value.is_a?(Array) dependency_value.each do |value| if !data.has_key?(value) message = "The property '#{build_fragment(fragments)}' has a property '#{property}' that depends on a missing property '#{value}'" raise ValidationError.new(message, fragments, current_schema) end end else schema = JSON::Schema.new(dependency_value,current_schema.uri,validator) schema.validate(data, fragments) end end end end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems