Sha256: 703ea7c6f24877f50a6922fc3168b08d30944722e87741af84ef907dcacfc9a3
Contents?: true
Size: 1022 Bytes
Versions: 1
Compression:
Stored size: 1022 Bytes
Contents
require 'json-schema/attribute' module JSON class Schema class PropertiesOptionalAttribute < Attribute def self.validate(current_schema, data, fragments, processor, validator, options = {}) if data.is_a?(Hash) current_schema.schema['properties'].each do |property,property_schema| if (property_schema['optional'].nil? || property_schema['optional'] == false) && !data.has_key?(property.to_s) 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.to_s) schema = JSON::Schema.new(property_schema,current_schema.uri,validator) fragments << property schema.validate(data[property],fragments,processor,options) fragments.pop end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
json-schema-2.4.1 | lib/json-schema/attributes/properties_optional.rb |