Benefits from validating in the controller?

#1
[eluser]Alexander Radsby[/eluser]
I've been thinking about why I should validate form data in the controller.

Let's say that I have a user with a username and a password.

I create a model named user.
Inside the user model I have the instance variables username and password.

These both have getters and setters.
How come that I don't validate the username and password in the setters instead?
If I do this I can make sure that every instance of the user model class is validated.

So I've been thinking of why I should validate in the controller? Isn't that repeating the same thing if I use the user model class in multiple controllers?


Messages In This Thread
Benefits from validating in the controller? - by El Forum - 01-23-2008, 12:21 PM
Benefits from validating in the controller? - by El Forum - 01-23-2008, 02:13 PM
Benefits from validating in the controller? - by El Forum - 01-23-2008, 02:55 PM
Benefits from validating in the controller? - by El Forum - 01-23-2008, 03:46 PM
Benefits from validating in the controller? - by El Forum - 01-23-2008, 09:12 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.