# Checking a schema with tv4

**URL:** <https://community.postman.com/t/checking-a-schema-with-tv4/7575>\
**Category:** Help Hub\
**Tags:** tests, tv4\
**Created:** [September 3, 2019, 11:53am UTC](https://community.postman.com/t/checking-a-schema-with-tv4/7575 "2019-09-03T11:53:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 4, 2019, 6:58am UTC](https://community.postman.com/t/checking-a-schema-with-tv4/7575/2 "2019-09-04T06:58:05Z")

</div>

Hey @Coxjeffrey,

I would recommend using [Ajv](https://github.com/epoberezkin/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 = {
   "type":"object",
   "required":[
      "Id",
      "Progress",
      "Status",
      "Info",
      "Created",
      "Ended",
      "Operation",
      "Requested"
   ],
   "properties":{
      "Id":{
         "$id":"#/properties/Id",
         "type":"string"
      },
      "Progress":{
         "$id":"#/properties/Progress",
         "type":"string"
      },
      "Status":{
         "$id":"#/properties/Status",
         "type":"string"
      },
      "Info":{
         "$id":"#/properties/Info",
         "type":"null"
      },
      "Created":{
         "$id":"#/properties/Created",
         "type":"string"
      },
      "Ended":{
         "$id":"#/properties/Ended",
         "type":"null"
      },
      "Operation":{
         "$id":"#/properties/Operation",
         "type":"string"
      },
      "Requested":{
         "$id":"#/properties/Requested",
         "type":"array",
         "items":{
            "$id":"#/properties/Requested/items",
            "type":"string"
         }
      }
   }
}

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

---

_[View the full topic](https://community.postman.com/t/checking-a-schema-with-tv4/7575)._
