# Better Schema Validator Error Messages

**URL:** <https://community.postman.com/t/better-schema-validator-error-messages/8505>\
**Category:** Help Hub\
**Created:** [October 22, 2019, 4:39pm UTC](https://community.postman.com/t/better-schema-validator-error-messages/8505 "2019-10-22T16:39:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshua](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@joshua](https://community.postman.com/u/joshua)\
**Post date:** [October 22, 2019, 4:39pm UTC](https://community.postman.com/t/better-schema-validator-error-messages/8505/1 "2019-10-22T16:39:38Z")

</div>

I have a test:

```
pm.test('schema valid', () => {
    const validation = tv4.validate(response, schema);
    
    if (!validation) {
        console.error(tv4.error)
    }

    pm.expect(validation || tv4.error.message).to.be.true;
})

```

I get a failure: `schema valid | AssertionError: expected 'Invalid type: null (expected string)' to be true`

There are 316 "null"s when I search for the result. How can I make this test give me a better message so I can find where it is failing?

The response is a JSON object with one property “products”. That property is an array of objects.

---

<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:** [October 22, 2019, 4:46pm UTC](https://community.postman.com/t/better-schema-validator-error-messages/8505/2 "2019-10-22T16:46:31Z")

</div>

Hey @joshua,

I would suggest switching over to using the Ajv module instead, it might have the solution you’re looking for, in terms of exposing more valuable error messages.

There have been a number of threads on the forums that have referenced how to do this:

> [@Checking a schema with tv4](https://community.postman.com/t/checking-a-schema-with-tv4/7575/2):
>
> 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/I…
