This is very simple and tested method of validation you can use in your project. Some time we need to add validation on fly in our controller then at that case you can use this code.

And second method is much easier than above technique you need to create custom method in your Model like below and define all rule

and you can call this where you can create entity in your controller.

Hope this tip help you to create run time validation in your cakephp 3 application 🙂

CakePHP 3 custom validation