Welcome Guest, Not a member yet? Register   Sign In
put Validation Rules to the Config File
#1

IN CI4,
I put the Validation Rules to the Config File(Validation)
Code:
    // Rules
    public $signup = [
       'username'     => 'required',
       'password'     => 'required',
       'pass_confirm' => 'required|matches[password]',
       'email'        => 'required|valid_email'
   ];

here I test it in Controller:



PHP Code:
            $validation  \Config\Services::validation();
            
$data=array(
                
'email'=>'',
                
'username'=>'',
            );
            
$validation->run($data$signup);
            
$errors $validation->getErrors();
            
print_r($errors); 
I got the ErrorException #1

Method CodeIgniter\HTTP\Header::__toString() must not throw an exception, caught ErrorException: Array to string conversion


 what went wrong?
Q&A for Codeigniter
StartBBS--open-source, light weight forum software.
Best VPS:Digital Ocean
Reply


Messages In This Thread
put Validation Rules to the Config File - by startbbs - 11-10-2016, 09:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB