This question mayt sound duplicate but I am not satisfied with any of the answers as some are suggesting MVC Foolproof validaiton
for conditional validaiton and some tells it dont work well with entity framework
I am using MVC Foolproof RequiredIf validation
in my project.It works well on clientside and is validation is working on server side as well.
[RequiredIf("STCompulsory",Operator.EqualTo,true,ErrorMessage="Please enter Registration No")]
public string STRegNo { get; set; }
But when i call db.Savechanges()
to insert data an exception is coming
An unexpected exception was thrown during validation of 'STRegNo' when invoking
Foolproof.RequiredIfAttribute.IsValid. See the inner exception for details.
InnerException
The method or operation is not implemented.