CodeIgniter Forums
How to use method setRule? - Printable Version

+- CodeIgniter Forums (
+-- Forum: CodeIgniter 4 (
+--- Forum: CodeIgniter 4 Discussion (
+--- Thread: How to use method setRule? (/thread-75298.html)

How to use method setRule? - 5flex - 01-23-2020

Sorry for my bad English.

Today I read Official User Guide about Validation Library. From the very beginning, the tutorial on this library has been going sequentially, but after the setRule() methods it breaks off and there is no logical conclusion just like a tutorial. I don't understand how to work the next code:

PHP Code:
Ok! I set up one rule for my form field. In tutorial wrote about it, but how to use and run the next checking? If in the condition I leave the code as in the example below, then the method setRule() has no effect. My form do not show any errors after send. What should I write in the condition if()? Another words - how to activate validation mechanism?

In my Controller I have:

PHP Code:
$validation =  \Config\Services::validation();


if (! 
            echo view('Signup', [
                'validation' => $this->validator
      echo view('Success');

and further... about 
In what cases can this method be applied? Can I have a simple example?

Thanks in advance.