Validation. In the View? or Service Layer?
<p>I am trying to figure out how to best do my validation for my mvc project. I come up with 2 ways but not sure which way is best(if any)</p>

<ol>
<li>Basic validation in my mvc controller(or whatever consumes my service layers) and business logic in the service layers.</li>
</ol>

<p>Once validation is done in the view the domain object would be passed and then checked for business logic and then saved to the db.</p>

<p>This means though that if I reuse my service layer every app will have to write validation for the same stuff(example "name" is required). If they forget to do this then the service layer will crash.</p>

<ol start="2">
<li>All validation done in the service layer. </li>
</ol>

<p>This would give one point of valdiation and would always ensure that all data is correct before saving to the db.</p>

<p>This creates in my opinion lots of overhead though as how I see it. I will need a viewmodel, then take the viewmodel and transfer it to a data transfer object, let that go into the service layer and validate it.</p>

<p>If it is valid then map it to the domain object and save it.</p>