CodeIgniter Forums
Use validation for a variable in controller or modal ci-4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Use validation for a variable in controller or modal ci-4 (/thread-74854.html)



Use validation for a variable in controller or modal ci-4 - ProfessionalCoder - 11-15-2019

hi sorry for english,

I want to use validation library for a email validation in controller manuel method ex. $validation->setRules(or all database request automatic method protected $validationRules protected $validationMessages in modal.

I have a $email variable . But I cant check this.what way ı should follow.


I try this



in modal 

protected $validationRules    = [
  'eposta'        => 'required|valid_email',
  'pass'    => 'required|min_length[8]'
];
protected $validationMessages = [
  'cari_eposta'        => [
      'valid_email' => 'Sorry. That email has already been taken. Please choose another.'
  ],
  'cari_sifre'        => [
      'min_length' => 'Sorry. That email has already been taken. Please choose another.'
  ]
];


It's problem its checking only insert,save and update.


In Controller I try this

$validation =  \Config\Services::validation();
$validation->setRules([
  'eposta'        => 'required|valid_email',
  'pass'    => 'required|min_length[8]'
]);


problem : I dont know use  this rules for $email in controller.

I dont want to problem solution with use post method and use form. I have only variable check with validation .