From 8c9edd5a2c37d9e80446e8ada0a99c59206348af Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 14 Jan 2019 09:09:41 -0500 Subject: Split out dependencies for draft 3. Draft 3 allowed simple string dependencies, but no later draft does. This also lets us use the same fix for boolean schema nonsense as we just did for items. --- jsonschema/_validators.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'jsonschema/_validators.py') diff --git a/jsonschema/_validators.py b/jsonschema/_validators.py index bb91643..8837d39 100644 --- a/jsonschema/_validators.py +++ b/jsonschema/_validators.py @@ -220,24 +220,16 @@ def dependencies(validator, dependencies, instance, schema): if property not in instance: continue - # FIXME - if dependency is True: - dependency = {} - elif dependency is False: - dependency = {"not": {}} - - if validator.is_type(dependency, "object"): + if validator.is_type(dependency, "array"): + for each in dependency: + if each not in instance: + message = "%r is a dependency of %r" + yield ValidationError(message % (each, property)) + else: for error in validator.descend( instance, dependency, schema_path=property, ): yield error - else: - dependencies = _utils.ensure_list(dependency) - for dependency in dependencies: - if dependency not in instance: - yield ValidationError( - "%r is a dependency of %r" % (dependency, property) - ) def enum(validator, enums, instance, schema): -- cgit v1.2.1