def self.validate(current_schema, data, fragments, processor, validator, options = {})
schema = current_schema.schema
return unless data.is_a?(Hash) && (schema['type'].nil? || schema['type'] == 'object')
extra_properties = remove_valid_properties(data.keys, current_schema, validator)
addprop = schema['additionalProperties']
if addprop.is_a?(Hash)
matching_properties = extra_properties
matching_properties.each do |key|
additional_property_schema = JSON::Schema.new(addprop, current_schema.uri, validator)
additional_property_schema.validate(data[key], fragments + [key], processor, options)
end
extra_properties -= matching_properties
end
if extra_properties.any? && (addprop == false || (addprop.is_a?(Hash) && !addprop.empty?))
message = "The property '#{build_fragment(fragments)}' contains additional properties #{extra_properties.inspect} outside of the schema when none are allowed"
validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
end
end