Sha256: 2c41b3832b0ad778a9915bbf6a851333ef621aa0a67ea977ff94b5445614db2d

Contents?: true

Size: 853 Bytes

Versions: 4

Compression:

Stored size: 853 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.to_s) || data.has_key?(property.to_sym)) && dependency_value.is_a?(Array)
              dependency_value.each do |value|
                if !data.has_key?(value.to_s)
                  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

4 entries across 4 versions & 1 rubygems

Version Path
json-schema-2.1.5 lib/json-schema/attributes/dependencies_v4.rb
json-schema-2.1.4 lib/json-schema/attributes/dependencies_v4.rb
json-schema-2.1.3 lib/json-schema/attributes/dependencies_v4.rb
json-schema-2.1.2 lib/json-schema/attributes/dependencies_v4.rb