CodeIgniter Forums
$this->validate bug? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: $this->validate bug? (/showthread.php?tid=68184)



$this->validate bug? - donpwinston - 06-06-2017

Code:
<?php namespace App\Controllers;

use CodeIgniter\Controller;

class Login extends Controller
{
    public function index()
    {
        helper('form');
        if (! $this->validate($this->request, []))
            print view('login');
        else
            print "It worked";
    }

    //--------------------------------------------------------------------

}


I get an error:
TypeError
Argument 2 passed to CodeIgniter\Validation\Validation:ConfusedetRules() must be of the type array, null given, called in /Users/satchwinston/Sites/CI4dev/system/Controller.php on line 187


Code:
public function validate(RequestInterface $request, $rules, array $messages = null): bool
183     {


Shouldn't "array $messages = null" be "array $messages = []"?


RE: $this->validate bug? - donpwinston - 06-07-2017

Looks like a new download of CI4 does not have this problem.