Custom Validation doesn't work? |
Hi, I want to create custom validation rule but it not working.
Config/Validation Code: public function test_validate(string $str, string &$error = null): bool App\Model Code: protected $validationRules = array( Result Quote:CodeIgniter\Validation\Exceptions\ValidationException For additional question, can someone give simpler example how to send parameters to the function? I don't get the 'require_with' example. https://codeigniter4.github.io/CodeIgnit...-parameter The new validation system is hard to understand compared to the previous callback system.
The way I did it:
Config/Validation.php PHP Code: /** Application/Validation/MyRules.php PHP Code: <?php namespace App\Validation; ..etc
Simpler is always better
Looks like you forgot to add it to the $ruleSets in Config/Validation.
Thanks for the reply. So the function needs to be put in different file?
I thought it was supposed to be placed below this line Code: //--------------------------------------------------------------------
You create a class whose member functions are your rules. Specify the class in the $ruleSets in Config/Validation.php.
Simpler is always better
|
Welcome Guest, Not a member yet? Register Sign In |