Validation in n-tier asp.net mvc applications
- by sTodorov
Dear Stack Overflow gurus,
I am looking for some practical/theoretical information regarding best practices for validation in asp.net mvc n-tier applications.
I am working on a .Net application divided into the following layers:
UI - Mvc3
BLL layer - all business rules. Decoupled from data access and UI layers through interfaces
DAL layer - Data access with the repository pattern, EF4 and pocos
Now, I am looking for a nice, clean and transparent way to specify my validation rules.
Here are some thoughts on the matter so far:
UI validation should only be responsible for user input and its validity.
BLL validation should be handling the validity of the data regarding the application business rules.
My main concern is how to bind the BLL and UI validation in the most efficient way. One think I am would like to avoid is having the UI check in a collection of validation and adding manually errors to the ModelState. Furthermore, I do not want to pass the ModelState to the BLL to be populated in there.
I will appreciate any thoughts on the matter.
P.S. Should this question be marked as a discussion ?