Sha256: 72dddf5b8e772dae2b744d3678aa20d29119af53abccf78bea87c96973c1a7fa

Contents?: true

Size: 741 Bytes

Versions: 16

Compression:

Stored size: 741 Bytes

Contents

require 'json-schema/attribute'

module JSON
  class Schema
    class PatternPropertiesAttribute < Attribute
      def self.validate(current_schema, data, fragments, processor, validator, options = {})
        return unless data.is_a?(Hash)

        current_schema.schema['patternProperties'].each do |property, property_schema|
          regexp = Regexp.new(property)

          # Check each key in the data hash to see if it matches the regex
          data.each do |key, value|
            next unless regexp.match(key)
            schema = JSON::Schema.new(property_schema, current_schema.uri, validator)
            schema.validate(data[key], fragments + [key], processor, options)
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 15 versions & 4 rubygems

Version Path
json-schema-ouidou-2.9.1 lib/json-schema/attributes/patternproperties.rb
json-schema-ouidou-2.9.0 lib/json-schema/attributes/patternproperties.rb
json-schema-3.0.0 lib/json-schema/attributes/patternproperties.rb
mountapi-0.11.1 vendor/json-schema/lib/json-schema/attributes/patternproperties.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/bundler/gems/json-schema-2253a5ee6679/lib/json-schema/attributes/patternproperties.rb
json-schema-2.8.1 lib/json-schema/attributes/patternproperties.rb
json-schema-2.8.0 lib/json-schema/attributes/patternproperties.rb
json-schema-2.7.0 lib/json-schema/attributes/patternproperties.rb
json-schema-2.6.2 lib/json-schema/attributes/patternproperties.rb
json-schema-2.6.1 lib/json-schema/attributes/patternproperties.rb
json-schema-2.6.0 lib/json-schema/attributes/patternproperties.rb
json-schema-2.5.2 lib/json-schema/attributes/patternproperties.rb
json-schema-openc-fork-0.0.2 lib/json-schema/attributes/patternproperties.rb
json-schema-2.5.1 lib/json-schema/attributes/patternproperties.rb
json-schema-openc-fork-0.0.1 lib/json-schema/attributes/patternproperties.rb
json-schema-2.5.0 lib/json-schema/attributes/patternproperties.rb