json_schema 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/json_schema/validator.rb +6 -0
- data/test/json_schema/validator_test.rb +9 -1
- metadata +2 -2
@@ -91,6 +91,12 @@ module JsonSchema
|
|
91
91
|
|
92
92
|
extra = data.keys - schema.properties.keys
|
93
93
|
|
94
|
+
if schema.pattern_properties
|
95
|
+
schema.pattern_properties.keys.each do |pattern|
|
96
|
+
extra -= extra.select { |k| k =~ pattern }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
94
100
|
# schema indicates that all properties not in `properties` should be
|
95
101
|
# validated according to subschema
|
96
102
|
if schema.additional_properties.is_a?(Schema)
|
@@ -301,9 +301,13 @@ describe JsonSchema::Validator do
|
|
301
301
|
|
302
302
|
it "validates additionalProperties boolean unsuccessfully" do
|
303
303
|
pointer("#/definitions/app").merge!(
|
304
|
-
"additionalProperties" => false
|
304
|
+
"additionalProperties" => false,
|
305
|
+
"patternProperties" => {
|
306
|
+
"^matches" => {}
|
307
|
+
}
|
305
308
|
)
|
306
309
|
data_sample["foo"] = "bar"
|
310
|
+
data_sample["matches-pattern"] = "yes!"
|
307
311
|
refute validate
|
308
312
|
assert_includes error_messages, %{Extra keys in object: foo.}
|
309
313
|
end
|
@@ -322,9 +326,13 @@ describe JsonSchema::Validator do
|
|
322
326
|
pointer("#/definitions/app").merge!(
|
323
327
|
"additionalProperties" => {
|
324
328
|
"type" => ["boolean"]
|
329
|
+
},
|
330
|
+
"patternProperties" => {
|
331
|
+
"^matches" => {}
|
325
332
|
}
|
326
333
|
)
|
327
334
|
data_sample["foo"] = 4
|
335
|
+
data_sample["matches-pattern"] = "yes!"
|
328
336
|
refute validate
|
329
337
|
assert_includes error_messages,
|
330
338
|
%{Expected data to be of type "boolean"; value was: 4.}
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|