json_schema 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -79,13 +79,7 @@ module Commands
79
79
 
80
80
  # Builds a JSON Reference + message like "/path/to/file#/path/to/data".
81
81
  def map_schema_errors(file, errors)
82
- errors.map { |e|
83
- if e.is_a?(JsonSchema::ValidationError)
84
- "#{file}#{e.pointer}: failed #{e.schema.pointer}: #{e.message}"
85
- else
86
- "#{file}#{e.schema.pointer}: #{e.message}"
87
- end
88
- }
82
+ JsonSchema::SchemaError.aggregate(errors).map { |m| "#{file}#{m}" }
89
83
  end
90
84
 
91
85
  def parse(file)
@@ -35,7 +35,7 @@ module JsonSchema
35
35
  def parse!(data, parent = nil)
36
36
  schema = parse(data, parent)
37
37
  if !schema
38
- raise SchemaError.aggregate(@errors)
38
+ raise SchemaError.aggregate(@errors).join(" ")
39
39
  end
40
40
  schema
41
41
  end
@@ -24,7 +24,7 @@ module JsonSchema
24
24
 
25
25
  def expand!(schema)
26
26
  if !expand(schema)
27
- raise SchemaError.aggregate(@errors)
27
+ raise SchemaError.aggregate(@errors).join(" ")
28
28
  end
29
29
  true
30
30
  end
@@ -4,17 +4,13 @@ module JsonSchema
4
4
  attr_accessor :schema
5
5
 
6
6
  def self.aggregate(errors)
7
- # May want to eventually use a JSON Pointer instead to help user narrow
8
- # down the location of the error. It's slightly tricky to ascend the
9
- # schema hierarchy to raise build one though, so I'm punting on that
10
- # for now.
11
7
  errors.map { |e|
12
- if e.schema
13
- %{#{e.schema.pointer}: #{e.message}}
8
+ if e.is_a?(ValidationError)
9
+ "#{e.pointer}: failed schema #{e.schema.pointer}: #{e.message}"
14
10
  else
15
- e.message
11
+ "#{e.schema.pointer}: #{e.message}"
16
12
  end
17
- }.join(" ")
13
+ }
18
14
  end
19
15
 
20
16
  def initialize(schema, message)
@@ -26,7 +26,7 @@ module JsonSchema
26
26
 
27
27
  def validate!(data)
28
28
  if !validate(data)
29
- raise SchemaError.aggregate(@errors)
29
+ raise SchemaError.aggregate(@errors).join(" ")
30
30
  end
31
31
  end
32
32
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: