Checking a schema with tv4


I’m trying to test a response body schema with tv4.
My test scrip I’m using is:

var schema = {
  "type": "object",
  "properties": {
            "Id": { "type": "string"},
            "Progress": { "type": "string"},
            "Status": { "type": "string"},
            "Info": { "type" : "boolean"},
            "Created": {"type": "string","format": "date-time"},
            "Ended": {"type": "boolean"},
            "Operation": {"type": "string"},
            "Requested": {"type": "array",
                "items" :{
                    "type": "string"

var user = JSON.parse(responseBody);
tests ["Success"] = tv4.validate(user, schema);

And the response body I get is:

    "Id": "29b61d38-1353-4c7f-9e8a-9f115ddef37f",
    "Progress": "Queued",
    "Status": "InProgress",
    "Info": null,
    "Created": "2019-09-03T00:00:00",
    "Ended": null,
    "Operation": "CalculateHolidayRightsCommand",
    "Requested": [

I’m getting a false error.

Hey @Coxjeffrey,

I would recommend using Ajv over tv4, this also comes as part of the Postman app.

You can use this example to check your response against the schema:

var Ajv = require('ajv'),
    ajv = new Ajv({ logger: console, allErrors: true }),
    schema = {

pm.test('Schema is valid', function() {
    pm.expect(ajv.validate(schema, pm.response.json()), JSON.stringify(ajv.errors));