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.



38
39
40
41
42
43
44
45
46
# File 'lib/json_schema/error.rb', line 38

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.



36
37
38
# File 'lib/json_schema/error.rb', line 36

def data
  @data
end

#pathObject

Returns the value of attribute path.



36
37
38
# File 'lib/json_schema/error.rb', line 36

def path
  @path
end

#sub_errorsObject

Returns the value of attribute sub_errors.



36
37
38
# File 'lib/json_schema/error.rb', line 36

def sub_errors
  @sub_errors
end

Instance Method Details

#pointerObject



48
49
50
# File 'lib/json_schema/error.rb', line 48

def pointer
  path.join("/")
end

#to_sObject



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

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