Conditional validation on model in MVC
If you’re on MVC3/.NET4, you can use IValidatableObject which exists specifically for such purposes. Quoting ScottGu, …The IValidatableObject interface enables you to perform model-level validation, and enables you to provide validation error messages specific to the state of the overall model…. You model would look like public class MyViewModel : IValidatableObject { public long? Id … Read more