# Testing Properties and Arrays correctly in GET

**URL:** <https://community.postman.com/t/testing-properties-and-arrays-correctly-in-get/7133>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [August 13, 2019, 2:53pm UTC](https://community.postman.com/t/testing-properties-and-arrays-correctly-in-get/7133 "2019-08-13T14:53:39Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![LiamC](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@LiamC](https://community.postman.com/u/LiamC)\
**Post date:** [August 16, 2019, 8:14am UTC](https://community.postman.com/t/testing-properties-and-arrays-correctly-in-get/7133/13 "2019-08-16T08:14:25Z")

</div>

I managed to get something to work, after banging my head against a wall for hours.  
I do agree this schema validation stuff may be a lot more than I can handle at the moment, so I may go back to what I had originally.

It’s been a learning experience though!

If you’re interested by the way, this is what I found would actually test Passes & fails correctly:

```auto
const jsonData = pm.response.json();

pm.test('Schema is valid', function() {
    var Ajv = require('ajv');
    ajv = new Ajv(),
    schema = { //Schema should contain an Array
        "type": "array",
        "items": {//In this Array there should be a Properties Object
                    "type": "object", //These are the properties within this object. This will test TYPE of Property.
                    "properties": {
                        "gameId": { "type": "integer" },
                        "name": { "type": "string" },
                        "description": { "type": "string" },
                        "minPlayers": { "type": "integer", "maximum": 1},
                        "maxPlayers": { "type": "integer", "maximum": 1},
                        "rating": {"type": "string" },
                        "online": {"type": "boolean" }
                        
            },"required" : ["gameId", "name", "description", "minPlayers", "maxPlayers", "rating", "online"]//Required will make sure that the Properties listed are present
        }
    };
    
    var validate = ajv.compile(schema);
    
    var valid = validate(jsonData)
    if(valid === false){
        console.log('Invalid: ' + ajv.errorsText(validate.errors));
    }
    
    pm.expect(valid).to.be.true;
  
});
```

Thank you

---

_[View the full topic](https://community.postman.com/t/testing-properties-and-arrays-correctly-in-get/7133)._
