code: def validate_json(data, validator):
      
      errors = []
      for err in sorted(validator.iter_errors(data), key=lambda e: e.path):
          if err.path:
              err_path = "[{}]".format(" -> ".join([str(p) for p in err.path]))
          else:
              err_path = ""
          msg = err.message + " " + err_path
          if err.context:  # Error has suberrors, e.g. if schema uses anyOf
              suberrs = ["  - {}".format(suberr.message) for suberr in err.context]
              msg += ":\n{}".format("".join(suberrs))
          errors.append(msg)
      return errors
docs: Validate data against a given JSON schema (see https://json-schema.org).
  
      data: JSON-serializable data to validate.
      validator (jsonschema.DraftXValidator): The validator.
      RETURNS (list): A list of error messages, if available.