Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter\Validation\Validation::setRules() must be of the type array, string given

(This post was last modified: 11-25-2018, 09:52 PM by NiteRaven.)

Hi there, I believe I found a bug with the controller validate method. The following doc page...


... states that I can pass the name of a validation group when validating POST data. This however is not that case as the Controller validate method only passes the rules to setRules as an array and generates a PHP error. It should check if the rules are a string or an array and then make the correct call to the validation service.

Something like:

PHP Code:
if (is_string($rules)) {
$success $this->validator->withRequest($this->request)->run();
} else {
$success $this->validator->withRequest($this->request)->setRules($rules$messages)->run();


This was fixed! Thanks!

processRules() function which inside System/Validation/validation.php 

I added this code and I fixed the problem. now validation work for  multiple variable  I sended like "name[]"

       if (is_array($value)) {
           foreach ($value as $k => $v) {
               $this->processRules($field, $label, $v, $rules, $data);
           return true;

You should never ever edit or change CodeIgniter system code!
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

(01-25-2019, 09:19 AM)InsiteFX Wrote:
You should never ever edit or change CodeIgniter system code!

I Agree but please tell me what is the way the validation for multiple array like name[] ?  

"dot array syntax " is not work..

This is the way I founded. What is yours?

Theme © iAndrew 2016 - Forum software by © MyBB