Sha256: 8fb505ae68698e2d6dd4f7545dcb0ada5445849c6bb63a783320de5acec64f59

Contents?: true

Size: 807 Bytes

Versions: 8

Compression:

Stored size: 807 Bytes

Contents

module JSON
  class Schema
    class DependenciesV4Attribute < Attribute
      def self.validate(current_schema, data, fragments, processor, validator, options = {})
        if data.is_a?(Hash)
          current_schema.schema['dependencies'].each do |property,dependency_value|
            if data.has_key?(property) && 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}'"
                  validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
json-schema-2.1.1 lib/json-schema/attributes/dependencies_v4.rb
json-schema-2.1.0 lib/json-schema/attributes/dependencies_v4.rb
json-schema-2.0.5 lib/json-schema/attributes/dependencies_v4.rb
json-schema-2.0.4 lib/json-schema/attributes/dependencies_v4.rb
json-schema-2.0.3 lib/json-schema/attributes/dependencies_v4.rb
json-schema-2.0.2 lib/json-schema/attributes/dependencies_v4.rb
json-schema-2.0.1 lib/json-schema/attributes/dependencies_v4.rb
json-schema-2.0.0 lib/json-schema/attributes/dependencies_v4.rb