# Generic Custom Validaton Page

**URL:** <https://discourse.cakephp.org/t/generic-custom-validaton-page/8061>\
**Category:** Need Help\
**Created:** [July 14, 2020, 7:27am UTC](https://discourse.cakephp.org/t/generic-custom-validaton-page/8061 "2020-07-14T07:27:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sneha](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@sneha](https://discourse.cakephp.org/u/sneha)\
**Post date:** [July 14, 2020, 7:27am UTC](https://discourse.cakephp.org/t/generic-custom-validaton-page/8061/1 "2020-07-14T07:27:33Z")

</div>

Hi there.

I want to create my custom generic validation page in cakephp 3.8. and access the functions through model in same way as cakephp does. I just want to create some some functions in a different page, that is accessible from any model.

Can anyone help??  
Thanx in advance.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [July 14, 2020, 2:22pm UTC](https://discourse.cakephp.org/t/generic-custom-validaton-page/8061/2 "2020-07-14T14:22:17Z")

</div>

It’s not clear what you’re trying to do. Can you share some example code that you’ve written towards this goal and explain what part you’re struggling with? Or give some more specific details about your idea?

---

<div class="post-metadata">

**Author:** ![sneha](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@sneha](https://discourse.cakephp.org/u/sneha)\
**Post date:** [July 15, 2020, 5:34am UTC](https://discourse.cakephp.org/t/generic-custom-validaton-page/8061/3 "2020-07-15T05:34:11Z")

</div>

I want to validate my entity according to my own function.

For example I want to check “Identification No” according to my own function in model.

$validator  
-\>MyOwnValidationFunction(‘id’);

Now, I have an option to define ‘MyOwnValidationFunction’ in same model. But in that case i wont be able to use this function in another model. To avoid such situation I want to create a separate page to define such validation functions that are accessible through all models.

Am I able to make myself more clear?

---

<div class="post-metadata">

**Author:** ![spadeX](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@spadeX](https://discourse.cakephp.org/u/spadeX)\
**Post date:** [July 15, 2020, 12:05pm UTC](https://discourse.cakephp.org/t/generic-custom-validaton-page/8061/4 "2020-07-15T12:05:16Z")

</div>

I think you can change the name of field that is (“id”) to another name so that this id will not use by another model

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [July 15, 2020, 1:31pm UTC](https://discourse.cakephp.org/t/generic-custom-validaton-page/8061/5 "2020-07-15T13:31:20Z")

</div>

> [@sneha](#):
>
> To avoid such situation I want to create a separate page to define such validation functions

The word “page” here is very much out of context. You maybe mean “class”?

It seems like you have read about [custom validation rules](https://book.cakephp.org/3/en/core-libraries/validation.html#using-custom-validation-rules), but not about [adding validation providers](https://book.cakephp.org/3/en/core-libraries/validation.html#adding-validation-providers) or [creating reusable validators](https://book.cakephp.org/3/en/core-libraries/validation.html#creating-reusable-validators).

---

<div class="post-metadata">

**Author:** ![sneha](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@sneha](https://discourse.cakephp.org/u/sneha)\
**Post date:** [July 15, 2020, 2:54pm UTC](https://discourse.cakephp.org/t/generic-custom-validaton-page/8061/6 "2020-07-15T14:54:13Z")

</div>

I have read about validation providers…but I am not able to implement into my application. If you can help??

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [July 15, 2020, 3:36pm UTC](https://discourse.cakephp.org/t/generic-custom-validaton-page/8061/7 "2020-07-15T15:36:22Z")

</div>

What is stopping you from implementing them? Without knowing specifically what is going wrong, it’s hard to help. The forums are for help with specific issues, not for writing your code for you; anyway, we have no idea what you want your validation code to do. Show us what you have tried, and explain what’s not working about it (including exact error messages if applicable).

---

<div class="post-metadata">

**Author:** ![dreamingmind](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dreamingmind/32/1857_2.png) [@dreamingmind](https://discourse.cakephp.org/u/dreamingmind)\
**Post date:** [July 15, 2020, 3:54pm UTC](https://discourse.cakephp.org/t/generic-custom-validaton-page/8061/8 "2020-07-15T15:54:33Z")

</div>

This sounds like a new skill that you are going to need to approach in stages.

If you can first get your custom validation rule running in a single table, then you can move on to making it reusable by many table classes.

Do you have your `checkIdentificationNo()` rule working properly in a single model?

---

<div class="post-metadata">

**Author:** ![sneha](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@sneha](https://discourse.cakephp.org/u/sneha)\
**Post date:** [July 16, 2020, 5:56am UTC](https://discourse.cakephp.org/t/generic-custom-validaton-page/8061/9 "2020-07-16T05:56:47Z")

</div>

Yeah the rule `checkIdentificationNo()` works for single table.

---

<div class="post-metadata">

**Author:** ![bizdev](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/bizdev/32/1951_2.png) [@bizdev](https://discourse.cakephp.org/u/bizdev)\
**Post date:** [July 16, 2020, 12:00pm UTC](https://discourse.cakephp.org/t/generic-custom-validaton-page/8061/10 "2020-07-16T12:00:51Z")

</div>

@sneha Please share some code with us so we know how you are implementing and in which area you want the help.
