Search code examples
c#asp.net-mvc-4foolproof-validation

Is it possible to use MVC Foolproof Validation in a domain model project


I am trying to validate two fields based on the URL entered using a RequiredIf data annotation provided by MVC Foolproof Validation, the project is an n-layer web application with business logic, data tier, presentation and unit testing layers.

The validation is currently being handled in the domain project found in the business logic layer, I have used this package successfully in other project but so far not got it to work in this project.

when I run the application in the web browser the field is not marked as required and the form can be submitted without entering one or other of these two fields.

for more details please refer to question I asked previously found here:

validating textboxes based on the URL entered

I have implemented a custom validator so far which does catch error but the user is unware that the field is actually required until they have submitted the form without entering a value.


Solution

  • After looking at a number of MVC 4 projects using an n-tier architecture, in particular ProDinner which can be found here:

    http://prodinner.codeplex.com/

    I have now decided to refactor the application so that the domain (core) now implements the model as POCOs and then the validation is implemented in a view model within the MVC project that inherits from the domain model.