# How to handle negative value validation in json schema

**URL:** <https://community.postman.com/t/how-to-handle-negative-value-validation-in-json-schema/5099>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [April 23, 2019, 1:14pm UTC](https://community.postman.com/t/how-to-handle-negative-value-validation-in-json-schema/5099 "2019-04-23T13:14:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaibhavbarmkar](https://avatars.discourse-cdn.com/v4/letter/v/ecd19e/32.png) [@vaibhavbarmkar](https://community.postman.com/u/vaibhavbarmkar)\
**Post date:** [April 23, 2019, 1:14pm UTC](https://community.postman.com/t/how-to-handle-negative-value-validation-in-json-schema/5099/1 "2019-04-23T13:14:31Z")

</div>

Hi, I’m facing an issue in schema validation. My response is having a negative value for json key but AJV validation is failing by saying “should be number”. I checked schema and its having type as “number”. Can someone help me validating negative values for any json key?

---

<div class="post-metadata">

**Author:** ![Rohit.s95](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@Rohit.s95](https://community.postman.com/u/Rohit.s95)\
**Post date:** [April 24, 2019, 4:15am UTC](https://community.postman.com/t/how-to-handle-negative-value-validation-in-json-schema/5099/2 "2019-04-24T04:15:03Z")

</div>

For schema validation which tool you are using  
postman  
or any other automation tool??  
@vaibhavbarmkar

---

<div class="post-metadata">

**Author:** ![vaibhavbarmkar](https://avatars.discourse-cdn.com/v4/letter/v/ecd19e/32.png) [@vaibhavbarmkar](https://community.postman.com/u/vaibhavbarmkar)\
**Post date:** [April 24, 2019, 10:17am UTC](https://community.postman.com/t/how-to-handle-negative-value-validation-in-json-schema/5099/3 "2019-04-24T10:17:43Z")

</div>

I’m using AJV lib of postman.

---

<div class="post-metadata">

**Author:** ![Whersh](https://avatars.discourse-cdn.com/v4/letter/w/9d8465/32.png) [@Whersh](https://community.postman.com/u/Whersh)\
**Post date:** [April 24, 2019, 2:51pm UTC](https://community.postman.com/t/how-to-handle-negative-value-validation-in-json-schema/5099/4 "2019-04-24T14:51:59Z")

</div>

Are you sure the value is coming back as a number and not a string? Is the failing value in quotes?

A simple Schema validation tool, although not always perfect, that I use is [https://www.jsonschemavalidator.net/](https://www.jsonschemavalidator.net/).

Place your schema in the left box and your failing response in the right box.

It will highlight were exactly it is failing and might give some more insight into what is happening.

---

<div class="post-metadata">

**Author:** ![shalaka-m](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@shalaka-m](https://community.postman.com/u/shalaka-m)\
**Post date:** [January 8, 2024, 3:50pm UTC](https://community.postman.com/t/how-to-handle-negative-value-validation-in-json-schema/5099/5 "2024-01-08T15:50:47Z")

</div>

did you find a solution for this ?

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [January 8, 2024, 5:07pm UTC](https://community.postman.com/t/how-to-handle-negative-value-validation-in-json-schema/5099/6 "2024-01-08T17:07:48Z")

</div>

This is a five year old question.

I would recommend creating your own topic, and including an example response, and details of your code for asserting the schema.

---

<div class="post-metadata">

**Author:** ![shalaka-m](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@shalaka-m](https://community.postman.com/u/shalaka-m)\
**Post date:** [January 8, 2024, 5:27pm UTC](https://community.postman.com/t/how-to-handle-negative-value-validation-in-json-schema/5099/7 "2024-01-08T17:27:07Z")

</div>

ok, thanks. will create my own post.
