Sha256: 054b711bacca6c56763e0dd0c863b93b16ad2217de4c9f40252cd58f17cd3b11

Contents?: true

Size: 619 Bytes

Versions: 3

Compression:

Stored size: 619 Bytes

Contents

module JsonSchema
  class SchemaError
    attr_accessor :message
    attr_accessor :schema

    def self.aggregate(errors)
      errors.map(&:to_s)
    end

    def initialize(schema, message)
      @schema = schema
      @message = message
    end

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

  class ValidationError < SchemaError
    attr_accessor :path

    def initialize(schema, path, message)
      super(schema, message)
      @path = path
    end

    def pointer
      path.join("/")
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json_schema-0.2.0 lib/json_schema/schema_error.rb
json_schema-0.1.8 lib/json_schema/schema_error.rb
json_schema-0.1.7 lib/json_schema/schema_error.rb