Welcome Guest, Not a member yet? Register   Sign In
Validation again - a big conceptual problem...
#1

[eluser]Multisnet[/eluser]
I think that I read all posts about validation in the forum, however I would like to know more opinions. My doubt is where to validate (model vs controller). I know that the opinions will diverge a lot, some of you prefer to validate the data in the model, others in the controller. Some people create a specif layer between model and controller to deal with validation. So I realize that there are a lot of approaches.

I'm working in some front-end forms, but in 1 month I'll be working in application's backend. If I validate the data in the controllers, I'll need to repeat all the validation in the backend forms. So, I'm thinking if it would be better to validate in the model.

My "conceptual" opinion is that some validation should remain in the business logic layer (e.g. username max. char. 12) and other in the data layer (e.g. in User constructor the username should be a required field, as we can't create a User without a username). My opinion is that some validation is more related with the logic of our application, other with the data itself (the basic validation for data). This approach would be a big nightmare to implement and maintain, it's only a conceptual idea.

I would like to know your opinions.


Messages In This Thread
Validation again - a big conceptual problem... - by El Forum - 06-23-2009, 05:37 AM
Validation again - a big conceptual problem... - by El Forum - 06-23-2009, 05:57 AM
Validation again - a big conceptual problem... - by El Forum - 06-23-2009, 06:07 AM
Validation again - a big conceptual problem... - by El Forum - 06-23-2009, 06:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB