title: How to validate json schema using avj and postman
body: <p>I'm trying to validate the following json that looks like this:</p>
  
  <pre><code>{
      "errors": false,
  }
  </code></pre>
  
  <p>using this on postman:</p>
  
  <pre><code>var Ajv = require('ajv'),
      ajv = new Ajv({logger: console, coerceTypes: false}),
      schema = {
  
          "errors": {
                  "type": "number"
              }
      };
  
  
  pm.test('Schema is valid', function() {
      var error = pm.response.json()['errors'];
      console.log("this is error: " +error);
      pm.expect(ajv.validate(schema, {errors: error})).to.be.true;
  });
  
  pm.test('Schema is valid different way', function() {
      var error = pm.response.json()['errors'];
      console.log("this is error: " +error);
      var validate = ajv.compile(schema);
      pm.expect(validate(pm.response.json())).to.be.true;
  });
  </code></pre>
  
  <p>but it's always passing, even though my errors object is a <code>boolean</code> and not a <code>number</code>. What am I doing wrong?</p>
  
  <p>note: the logs look like this</p>
  
  <pre><code>this is error: false
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mtpSH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mtpSH.png" alt="enter image description here"></a></p>