class JSON::Schema::Validator

Attributes

attributes[RW]
default_formats[R]
formats[RW]
names[RW]
uri[RW]

Public Class Methods

new() click to toggle source
# File lib/json-schema/schema/validator.rb, line 7
def initialize()
  @attributes = {}
  @formats = {}
  @default_formats = {}
  @uri = nil
  @names = []
  @metaschema_name = ''
end

Public Instance Methods

extend_schema_definition(schema_uri) click to toggle source
# File lib/json-schema/schema/validator.rb, line 16
def extend_schema_definition(schema_uri)
  warn "[DEPRECATION NOTICE] The preferred way to extend a Validator is by subclassing, rather than #extend_schema_definition. This method will be removed in version >= 3."
  validator = JSON::Validator.validator_for_uri(schema_uri)
  @attributes.merge!(validator.attributes)
end
metaschema() click to toggle source
# File lib/json-schema/schema/validator.rb, line 31
def metaschema
  resources = File.expand_path('../../../../resources', __FILE__)
  File.join(resources, @metaschema_name)
end
validate(current_schema, data, fragments, processor, options = {}) click to toggle source
# File lib/json-schema/schema/validator.rb, line 22
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