# How to validate the contents in the request body

**URL:** <https://community.postman.com/t/how-to-validate-the-contents-in-the-request-body/13566>\
**Category:** Help Hub\
**Created:** [June 22, 2020, 4:13am UTC](https://community.postman.com/t/how-to-validate-the-contents-in-the-request-body/13566 "2020-06-22T04:13:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sopau](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sopau](https://community.postman.com/u/sopau)\
**Post date:** [June 22, 2020, 4:13am UTC](https://community.postman.com/t/how-to-validate-the-contents-in-the-request-body/13566/1 "2020-06-22T04:13:54Z")

</div>

Is there a way to validate the contents in the request body before sending the request.  
for example ,

1. To validate if a particular xml tag appears twice.
2. To check if a particular xml value is present in xml

Postman version:win64-7.25.0

---

<div class="post-metadata">

**Author:** ![amit](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/amit/32/2056_2.png) [@amit](https://community.postman.com/u/amit)\
**Post date:** [June 22, 2020, 4:33am UTC](https://community.postman.com/t/how-to-validate-the-contents-in-the-request-body/13566/2 "2020-06-22T04:33:12Z")

</div>

Hey @sopau, welcome to the community! 👋

You most certainly can validate data before it’s used in the request being sent.

For this, you would need to add code to the “[Pre-request Script](https://learning.postman.com/docs/postman/scripts/pre-request-scripts/)” which is executed before the request is sent!

[Postman Sandbox](https://learning.postman.com/docs/postman/scripts/postman-sandbox-api-reference/) comes bundled with popular Node.js modules that should help you manipulate and use XML data.

checkout [Cheerio](https://cheerio.js.org/) and [xml2js](https://www.npmjs.com/package/xml2js) modules which should come useful to handle XML data.

Also, have a look at this post: [Working with XML in Postman Scripts](https://community.postman.com/t/working-with-xml-in-postman-scripts/8649) , linking to a tutorial-video, which looks to be pretty comprehensive! 👍
