I currently have a form that I am building that needs to support two different versions. Each version might use a different subset of form fields. I have to do this to support two different clients, but I don't want to have entirely different controller actions for both.
So, I am trying to come up with a way to use a strongly typed model with validation attributes but have some of these attributes be conditional.
Some approaches I can think of is similar to steve sanderson's partial validation approach.
Where I would clear the model errors in a filter OnActionExecuting based on which version of the form was active.
The other approach I was thinking of would to break the model up into pieces using something like
class FormModel
{
public Form1 Form1Model {get; set;}
public Form2 FormModel {get; set;}
}
and then find some way to just validate the appropriate property depending on the version. There would also be common properties on the model that apply to both which would be always validated.
Does anyone have a good suggestion on this?