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 { |
|
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)
|
data/lib/json_schema/parser.rb
CHANGED
@@ -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.
|
13
|
-
|
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
|
-
}
|
13
|
+
}
|
18
14
|
end
|
19
15
|
|
20
16
|
def initialize(schema, message)
|