Sha256: 2f8281b7010000a4585b1a7ae67aae3337d5d64c2fcbdadcbdc1e02d3f3d531d
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
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) && !data.has_key?(property.to_sym)) 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) || data.has_key?(property.to_sym) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
json-schema-2.4.0 | lib/json-schema/attributes/properties_optional.rb |
json-schema-2.3.0 | lib/json-schema/attributes/properties_optional.rb |