Generic Custom Validaton Page

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.

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?

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?

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

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

It seems like you have read about custom validation rules, but not about adding validation providers or creating reusable validators.

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

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).

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?

Yeah the rule checkIdentificationNo() works for single table.

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