Welcome Guest, Not a member yet? Register   Sign In
Best way to implement validation rules
#4

(This post was last modified: 02-10-2021, 07:41 PM by falcon812311.)

(02-10-2021, 12:01 PM)jasonzig Wrote:
(02-10-2021, 07:33 AM)falcon812311 Wrote: Hi, 

I'm developing a system for large scope project. I'm very confuse with validation in the CodeIgniter guide/documentation  it is hard to understand.

What is the best strategy to store validation rule?
Use Validation service or Controller or Models?


Huh

If you referring to data-entity validation during db INSERT/UPDATE/DELETE operations,
the setValidationRule method is mentioned in the docs (https://codeigniter.com/user_guide/model...dationRule) as taking place in the model.

Please keep us updated on how your project goes!

Incidentally, how did you select CodeIgniter4?

I love CodeIgniter4 because it is easy to understand and fast! This is my website (https://jaironlanda.com) I'm develop using latest version CodeIgniter 4. 

Unfortunately, the useguide is hard to understand. It is hard to find the right way to use validation, library, custom model, and etc. Sometime I refer from youtube (https://www.youtube.com/channel/UCIbtEs1...bgD_ake7HA) he is good, he show example how use and how its work!

So back to my question about validation rule. I wonder when to use Validation in Models, Validation in Controller, and Validation service?

(02-10-2021, 01:07 PM)adnzaki Wrote: I used to store validation in controllers. I just create a method containing rules and messages, so it can be used by one or more methods. I usually make a separation between the app and database by its controller and model. Every data should pass validation in controller before they sent to model to be inserted to database.
 
How you make separation between the app and database? you put all validation rules here? 
PHP Code:
Config\Validation.php 

Thanks!
This is me. JK not me.
Reply


Messages In This Thread
RE: Best way to implement validation rules - by falcon812311 - 02-10-2021, 07:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB