# Validation and buildRules with custom condition

**URL:** <https://discourse.cakephp.org/t/validation-and-buildrules-with-custom-condition/3249>\
**Category:** Need Help\
**Created:** [September 21, 2017, 5:28pm UTC](https://discourse.cakephp.org/t/validation-and-buildrules-with-custom-condition/3249 "2017-09-21T17:28:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheMiller](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@TheMiller](https://discourse.cakephp.org/u/TheMiller)\
**Post date:** [September 21, 2017, 5:28pm UTC](https://discourse.cakephp.org/t/validation-and-buildrules-with-custom-condition/3249/1 "2017-09-21T17:28:31Z")

</div>

Hello,

I have an API that calls cakePHP Rest Api. That api can’t handle “null” in an integer field (c#). Is it possible to modify validators and/or buildRules that way, that the “existsIn”-Check is only executed, when the value (here of “archive\_id”) is greater than 0?

I tried many possibilities and read the cookbook, but had no luck with that task.

Please help me with the powerful validation of Cake.

Thank in advance!

---

<div class="post-metadata">

**Author:** ![syed](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@syed](https://discourse.cakephp.org/u/syed)\
**Post date:** [September 22, 2017, 1:11pm UTC](https://discourse.cakephp.org/t/validation-and-buildrules-with-custom-condition/3249/2 "2017-09-22T13:11:43Z")

</div>

This is how you can customize Data Validation, check this link.  
[https://book.cakephp.org/3.0/en/orm/validation.html#creating-a-rules-checker](https://book.cakephp.org/3.0/en/orm/validation.html#creating-a-rules-checker)
