diff options
author | Julian Berman <Julian@GrayVines.com> | 2013-10-17 19:18:56 -0700 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2013-10-17 19:18:56 -0700 |
commit | b6ede007ae7a6b57cf775776337d09261ddc3134 (patch) | |
tree | 4478cf82773060d30e99f63d003607a35c4c2105 | |
parent | 333c5d8effb42de3d66296522fb7b8ed07b34b37 (diff) | |
parent | 3baddb61a36dfdeef0c4e8cff5033b4815c956b4 (diff) | |
download | jsonschema-b6ede007ae7a6b57cf775776337d09261ddc3134.tar.gz |
Merge pull request #129 from sontek/handle_non_string_types
Allow non-string custom types (arbitrary objects).
-rw-r--r-- | jsonschema/_validators.py | 2 | ||||
-rw-r--r-- | jsonschema/tests/test_validators.py | 5 |
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 |