Sha256: b1385d640b0892abdbfc6ec72ba61442eae8dd7ecbdd69feb40faa200bb6ab57
Contents?: true
Size: 975 Bytes
Versions: 25
Compression:
Stored size: 975 Bytes
Contents
require 'json-schema/attribute' module JSON class Schema class PropertiesOptionalAttribute < Attribute def self.validate(current_schema, data, fragments, processor, validator, options = {}) return unless data.is_a?(Hash) schema = current_schema.schema schema['properties'].each do |property, property_schema| property = property.to_s if !property_schema['optional'] && !data.key?(property) message = "The property '#{build_fragment(fragments)}' did not contain a required property of '#{property}'" validation_error(processor, message, fragments, current_schema, self, options[:record_errors]) end if data.has_key?(property) expected_schema = JSON::Schema.new(property_schema, current_schema.uri, validator) expected_schema.validate(data[property], fragments + [property], processor, options) end end end end end end
Version data entries
25 entries across 24 versions & 4 rubygems