summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Anderson <sontek@gmail.com>2013-10-17 19:13:58 -0700
committerJohn Anderson <sontek@gmail.com>2013-10-17 19:13:58 -0700
commit3baddb61a36dfdeef0c4e8cff5033b4815c956b4 (patch)
tree4478cf82773060d30e99f63d003607a35c4c2105
parent333c5d8effb42de3d66296522fb7b8ed07b34b37 (diff)
downloadjsonschema-3baddb61a36dfdeef0c4e8cff5033b4815c956b4.tar.gz
This allows defining custom types
-rw-r--r--jsonschema/_validators.py2
-rw-r--r--jsonschema/tests/test_validators.py5
2 files changed, 6 insertions, 1 deletions
diff --git a/jsonschema/_validators.py b/jsonschema/_validators.py
index bfcd1c1..c8cf05c 100644
--- a/jsonschema/_validators.py
+++ b/jsonschema/_validators.py
@@ -215,7 +215,7 @@ def type_draft3(validator, types, instance, schema):
if not errors:
return
all_errors.extend(errors)
- elif validator.is_type(type, "string"):
+ else:
if validator.is_type(instance, type):
return
else:
diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py
index 357e388..1081ec1 100644
--- a/jsonschema/tests/test_validators.py
+++ b/jsonschema/tests/test_validators.py
@@ -655,6 +655,11 @@ class TestDraft3Validator(ValidatorTestMixin, unittest.TestCase):
self.assertTrue(self.validator.is_type(True, "boolean"))
self.assertTrue(self.validator.is_valid(True, {"type": "any"}))
+ def test_non_string_custom_types(self):
+ schema = {'type': [None]}
+ cls = self.validator_class(schema, types={None: type(None)})
+ cls.validate(None, schema)
+
class TestDraft4Validator(ValidatorTestMixin, unittest.TestCase):
validator_class = Draft4Validator