Exception: JsonSchema::ValidationError

Inherits:
SchemaError show all
Defined in:
lib/json_schema/error.rb

Instance Attribute Summary collapse

Attributes inherited from SchemaError

#message, #schema, #type

Instance Method Summary collapse

Methods inherited from SchemaError

aggregate

Constructor Details

#initialize(schema, path, message, type, options = {}) ⇒ ValidationError

Returns a new instance of ValidationError.


42
43
44
45
46
47
48
49
50
# File 'lib/json_schema/error.rb', line 42

def initialize(schema, path, message, type, options = {})
  super(schema, message, type)
  @path = path

  # TODO: change to named optional arguments when Ruby 1.9 support is
  # removed
  @data = options[:data]
  @sub_errors = options[:sub_errors]
end

Instance Attribute Details

#dataObject

Returns the value of attribute data


40
41
42
# File 'lib/json_schema/error.rb', line 40

def data
  @data
end

#pathObject

Returns the value of attribute path


40
41
42
# File 'lib/json_schema/error.rb', line 40

def path
  @path
end

#sub_errorsObject

Returns the value of attribute sub_errors


40
41
42
# File 'lib/json_schema/error.rb', line 40

def sub_errors
  @sub_errors
end

Instance Method Details

#pointerObject


52
53
54
# File 'lib/json_schema/error.rb', line 52

def pointer
  path.join("/")
end

#to_sObject


56
57
58
# File 'lib/json_schema/error.rb', line 56

def to_s
  "#{pointer}: failed schema #{schema.pointer}: #{message}"
end