# Validate format data

**URL:** <https://community.postman.com/t/validate-format-data/11307>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [March 11, 2020, 5:49pm UTC](https://community.postman.com/t/validate-format-data/11307 "2020-03-11T17:49:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![danuzagaia](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@danuzagaia](https://community.postman.com/u/danuzagaia)\
**Post date:** [March 11, 2020, 5:49pm UTC](https://community.postman.com/t/validate-format-data/11307/1 "2020-03-11T17:49:42Z")

</div>

How can I validate data format with Postman?

I have the following response body:

“value”: [  
{  
“cotacaoCompra”: 4.08520,  
“cotacaoVenda”: 4.08580,  
“dataHoraCotacao”: “2019-10-22 13:10:34.471”  
}  
]

I need to validate that “cotacaoCompra” has the format “0.00000”

Please, help me!

---

<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:** [March 11, 2020, 9:22pm UTC](https://community.postman.com/t/validate-format-data/11307/2 "2020-03-11T21:22:44Z")

</div>

You could use the `.match()` function from the chai assertion library and use regex to check the format:

```
let jsonData = pm.response.json();
pm.test("Check value is correct", () => {  
  pm.expect(jsonData.value[0].cotacaoCompra).to.match(/\d{1}.\d{5}/);
});
```

---

<div class="post-metadata">

**Author:** ![danuzagaia](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@danuzagaia](https://community.postman.com/u/danuzagaia)\
**Post date:** [March 12, 2020, 2:13am UTC](https://community.postman.com/t/validate-format-data/11307/3 "2020-03-12T02:13:34Z")

</div>

It’s not working here.  
Result: AssertionError: expected 4.0852 to match /\d{1}.\d{5}/

Apparently postman is not recognizing regex.

---

<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:** [March 12, 2020, 7:03am UTC](https://community.postman.com/t/validate-format-data/11307/4 "2020-03-12T07:03:39Z")

</div>

It looks like the last 0 is missing from the response value so it’s failing to match the pattern.

---

<div class="post-metadata">

**Author:** ![danuzagaia](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@danuzagaia](https://community.postman.com/u/danuzagaia)\
**Post date:** [March 12, 2020, 2:03pm UTC](https://community.postman.com/t/validate-format-data/11307/5 "2020-03-12T14:03:27Z")

</div>

You are right. It works now. But if I test with the regex (/\d{1}.\d{3}/) the test pass also.
