# Validating Json array using java script

**URL:** <https://community.postman.com/t/validating-json-array-using-java-script/13721>\
**Category:** Help Hub\
**Tags:** json-arra, json-array-validatio, json-response\
**Created:** [June 29, 2020, 8:00am UTC](https://community.postman.com/t/validating-json-array-using-java-script/13721 "2020-06-29T08:00:47Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [June 29, 2020, 12:58pm UTC](https://community.postman.com/t/validating-json-array-using-java-script/13721/4 "2020-06-29T12:58:21Z")

</div>

You could use something like this to loop through and filter the objects that contain `items` greater than `300`. It will create an array that you can assert against the length of to see if it’s above `1`.

I’ve added in a custom error string that shows you why it failed.

```
pm.test('Is atleast one of the batch in future >=300', () => {
    let result = pm.response.json().filter(arr => arr.items >= 300)
    pm.expect(result.length).to.be.above(1, `Objects matching condition ${result.length}`)
})

```

This will give you an idea of other assertions that could be made in the `pm.expect()` statements:

[https://www.chaijs.com/api/bdd/](https://www.chaijs.com/api/bdd/)

---

_[View the full topic](https://community.postman.com/t/validating-json-array-using-java-script/13721)._
