def validate_json(data, validator):
errors = []<EOL>for err in sorted(validator.iter_errors(data), key=lambda e: e.path):<EOL><INDENT>if err.path:<EOL><INDENT>err_path = "<STR_LIT>".format("<STR_LIT>".join([str(p) for p in err.path]))<EOL><DEDENT>else:<EOL><INDENT>err_path = "<STR_LIT>"<EOL><DEDENT>msg = err.message + "<STR_LIT:U+0020>" + err_path<EOL>if err.context:  <EOL><INDENT>suberrs = ["<STR_LIT>".format(suberr.message) for suberr in err.context]<EOL>msg += "<STR_LIT>".format("<STR_LIT>".join(suberrs))<EOL><DEDENT>errors.append(msg)<EOL><DEDENT>return errors<EOL>
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.