code: def additionalProperties(validator, aP, instance, schema):
      if not validator.is_type(instance, "object"):
          return
  
      extras = set(find_additional_properties(instance, schema))
  
      if validator.is_type(aP, "object"):
          for extra in extras:
              for error in validator.descend(
                  instance[extra], aP, path=extra
              ):
                  yield error
      elif not aP and extras:
          if "patternProperties" in schema:
              patterns = sorted(schema["patternProperties"])
              if len(extras) == 1:
                  verb = "does"
              else:
                  verb = "do"
              error = "%s %s not match any of the regexes: %s" % (
                  ", ".join(map(repr, sorted(extras))),
                  verb,
                  ", ".join(map(repr, patterns)),
              )
              yield ValidationError(error)
          else:
              error = "Additional properties are not allowed (%s %s unexpected)"
              yield ValidationError(error % extras_msg(extras))
  
imports: import re
  from jsonschema._utils import ensure_list, equal, extras_msg, find_additional_properties, types_msg, unbool, uniq
  from jsonschema.exceptions import FormatError, ValidationError
  from jsonschema.compat import iteritems
label_desc: Use image node_id 3 for calling a global function with example usage: additionalProperties(validator, aP, instance, schema) without return types