Sha256: 3079098bc5b9c1e2dbcaa1a9b28921a2cf03c1a4124d557c50aeeae9459290ca

Contents?: true

Size: 1001 Bytes

Versions: 11

Compression:

Stored size: 1001 Bytes

Contents

module JSON
  class Schema
    class Validator
      attr_accessor :attributes, :formats, :uri, :names
      attr_reader :default_formats

      def initialize()
        @attributes = {}
        @formats = {}
        @default_formats = {}
        @uri = nil
        @names = []
        @metaschema_name = ''
      end

      def extend_schema_definition(schema_uri)
        validator = JSON::Validator.validator_for(schema_uri)
        @attributes.merge!(validator.attributes)
      end

      def validate(current_schema, data, fragments, processor, options = {})
        current_schema.schema.each do |attr_name,attribute|
          if @attributes.has_key?(attr_name.to_s)
            @attributes[attr_name.to_s].validate(current_schema, data, fragments, processor, self, options)
          end
        end
        data
      end

      def metaschema
        resources = File.expand_path('../../../../resources', __FILE__)
        File.join(resources, @metaschema_name)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
json-schema-2.7.0 lib/json-schema/schema/validator.rb
json-schema-2.6.2 lib/json-schema/schema/validator.rb
json-schema-2.6.1 lib/json-schema/schema/validator.rb
json-schema-2.6.0 lib/json-schema/schema/validator.rb
json-schema-2.5.2 lib/json-schema/schema/validator.rb
json-schema-openc-fork-0.0.2 lib/json-schema/schema/validator.rb
json-schema-2.5.1 lib/json-schema/schema/validator.rb
json-schema-openc-fork-0.0.1 lib/json-schema/schema/validator.rb
json-schema-2.5.0 lib/json-schema/schema/validator.rb
json-schema-2.4.1 lib/json-schema/schema/validator.rb
json-schema-2.4.0 lib/json-schema/schema/validator.rb