Own validation rules with CodeIgniter >4.5 |
Based on the CodeIgniter documentation on validation, there are still a few things that are a bit unclear to me, so I wanted to ask here for advice on whether my approach is in line with best practice and how you would implement it.
https://codeigniter.com/user_guide/libra...ation.html I have created a new class under app/Validation/NewsletterRules.php: PHP Code: <?php And registered them accordingly under app/Config/Validation.php: PHP Code: public array $ruleSets = [ Now I would do the following in the controller: PHP Code: $validation = service('validation'); Would this be the correct / best possible procedure? Are there more elegant ways? Do you prefer the validation rules in the controller or in the model? In general, most frameworks seem to leave the validation completely to the controller? I am also a bit confused by the statement at $validation = service('validation'); What exactly does this mean? Isn't it used in the example itself? Quote:"You may never need to use this method, as both the Controller and the Model provide methods to make validation even easier." Thank you very much for your thoughts! |
Messages In This Thread |
Own validation rules with CodeIgniter >4.5 - by minsk832 - 02-05-2025, 09:08 AM
RE: Own validation rules with CodeIgniter >4.5 - by ozornick - 02-05-2025, 12:35 PM
RE: Own validation rules with CodeIgniter >4.5 - by minsk832 - 02-05-2025, 02:27 PM
RE: Own validation rules with CodeIgniter >4.5 - by grimpirate - 02-05-2025, 07:13 PM
RE: Own validation rules with CodeIgniter >4.5 - by ozornick - 02-05-2025, 10:36 PM
RE: Own validation rules with CodeIgniter >4.5 - by minsk832 - 02-07-2025, 04:49 PM
RE: Own validation rules with CodeIgniter >4.5 - by grimpirate - 02-07-2025, 06:31 PM
RE: Own validation rules with CodeIgniter >4.5 - by ozornick - 02-08-2025, 12:33 AM
RE: Own validation rules with CodeIgniter >4.5 - by grimpirate - 02-08-2025, 11:26 AM
RE: Own validation rules with CodeIgniter >4.5 - by ozornick - 02-08-2025, 01:38 PM
RE: Own validation rules with CodeIgniter >4.5 - by grimpirate - 02-08-2025, 02:28 PM
|