test/test_jsonschema_draft4.rb in json-schema-2.2.0 vs test/test_jsonschema_draft4.rb in json-schema-2.2.1
- old
+ new
@@ -461,10 +461,40 @@
data = {"a" => "a", "b" => "b", "c" => 3}
assert(JSON::Validator.validate(schema,data,:strict => true))
end
+ def test_strict_properties_pattern_props
+ schema = {
+ "$schema" => "http://json-schema.org/draft-03/schema#",
+ "properties" => {
+ "a" => {"type" => "string"},
+ "b" => {"type" => "string"}
+ },
+ "patternProperties" => {"\\d+ taco" => {"type" => "integer"}}
+ }
+ data = {"a" => "a"}
+ assert(!JSON::Validator.validate(schema,data,:strict => true))
+
+ data = {"b" => "b"}
+ assert(!JSON::Validator.validate(schema,data,:strict => true))
+
+ data = {"a" => "a", "b" => "b"}
+ assert(JSON::Validator.validate(schema,data,:strict => true))
+
+ data = {"a" => "a", "b" => "b", "c" => "c"}
+ assert(!JSON::Validator.validate(schema,data,:strict => true))
+
+ data = {"a" => "a", "b" => "b", "c" => 3}
+ assert(!JSON::Validator.validate(schema,data,:strict => true))
+
+ data = {"a" => "a", "b" => "b", "23 taco" => 3}
+ assert(JSON::Validator.validate(schema,data,:strict => true))
+
+ data = {"a" => "a", "b" => "b", "23 taco" => "cheese"}
+ assert(!JSON::Validator.validate(schema,data,:strict => true))
+ end
def test_unique_items
# Set up the default datatype
schema = {
"$schema" => "http://json-schema.org/draft-04/schema#",