Sha256: 50adc7cb74525f8b5503a18d1ca4bfd83b795356ffedebbb75d176c7b754d7cf
Contents?: true
Size: 1.18 KB
Versions: 8
Compression:
Stored size: 1.18 KB
Contents
module JSON class Schema class PropertiesAttribute < 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 !data.has_key?(property) and property_schema['default'] and !property_schema['readonly'] and options[:insert_defaults] default = property_schema['default'] data[property] = (default.is_a?(Hash) ? default.clone : default) end if property_schema['required'] and !data.has_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) 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
8 entries across 8 versions & 1 rubygems