From 3baddb61a36dfdeef0c4e8cff5033b4815c956b4 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Thu, 17 Oct 2013 19:13:58 -0700 Subject: This allows defining custom types --- jsonschema/_validators.py | 2 +- jsonschema/tests/test_validators.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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 -- cgit v1.2.1