Load HL7 FHIR schema/profile extension and validate response in tests

My question:
I am very new to Postman and am trying to figure out if I can use the tests as a “one-stop” testing source, both checking for correct responses in tests and conformance to structures.

We have set up a FHIR server, which in theory should return FHIR schema compliant resources. There are also extensions (additional constraints) that build on these, called profiles - I have some built out.

FHIR has a java-based validation tool that you can run a response against and it’ll tell you if it is compliant. Example of what that looks like:

So, I wondered if I could do something similar, with tiny validator, in tests, based on the suggested snippets. I decided to try first with just the basic FHIR schema. The schema definition uses JSON Schema draft-06 and is found here: direct link and download page.

I set up requests in a folder under a collection, and put the following into the folder’s pre-request script:

var fhir_r4_schema_json = { <json copy+paste from downloaded file above>};

pm.globals.set("fhir_r4_schema", fhir_r4_schema_json);

I created a Resource request for an item (e.g., Location), which returns the JSON-formatted result.
In the test section, I put the following:

pm.test('Conformance schema is valid', function () {
    pm.expect(tv4.validate(pm.response.json(), pm.globals.get("fhir_r4_schema"))).to.be.true;

which fails. The resource as-is passes using the java-based tool:


Is this even something that is possible with Postman? Am I going about it totally wrong?