Sha256: 231d1d38e70abef792b03420d04681741b4744f38cb0a327a4d74894adb0209f
Contents?: true
Size: 958 Bytes
Versions: 9
Compression:
Stored size: 958 Bytes
Contents
module JSON class Schema class PropertiesOptionalAttribute < Attribute def self.validate(current_schema, data, fragments, 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)) message = "The property '#{build_fragment(fragments)}' did not contain a required property of '#{property}'" validation_error(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,options) fragments.pop end end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems