def load_and_validate(document_loader,                 <EOL>avsc_names,                      <EOL>document,                        <EOL>strict,                          <EOL>strict_foreign_properties=False  <EOL>):<EOL>
try:<EOL><INDENT>if isinstance(document, CommentedMap):<EOL><INDENT>data, metadata = document_loader.resolve_all(<EOL>document, document["<STR_LIT:id>"], checklinks=True,<EOL>strict_foreign_properties=strict_foreign_properties)<EOL><DEDENT>else:<EOL><INDENT>data, metadata = document_loader.resolve_ref(<EOL>document, checklinks=True,<EOL>strict_foreign_properties=strict_foreign_properties)<EOL><DEDENT>validate_doc(avsc_names, data, document_loader, strict,<EOL>strict_foreign_properties=strict_foreign_properties)<EOL>return data, metadata<EOL><DEDENT>except validate.ValidationException as exc:<EOL><INDENT>raise validate.ValidationException(strip_dup_lineno(str(exc)))<EOL><DEDENT>
Load a document and validate it with the provided schema.

    return data, metadata