We are trying to use the Foolproof validation annotation [RequiredIf]
to check if an email address is needed. We also created an enum to avoid using a lookup table id in the ViewModel. The code looks like this:
public enum NotificationMethods {
Email = 1,
Fax = 2
}
Then in the ViewModel:
[RequiredIf("NotificationMethodID", NotificationMethods.Email)]
public string email {get; set;}
In this senario we do not get an error when email is unfilled but selected as the notification type. Conversely this works as expected:
[RequiredIf("NotificationMethodID", 1)]
public string email {get; set;}
The only other reference to this I have found is here: https://foolproof.codeplex.com/workitem/17245