MVC Server Side Validation RequiredIfTrue

Apr 11, 2016 at 11:35 AM
I am using Foolproof Validation . When calling
[RequiredIfTrue("CommonUseStatus")]
Foolproof ReqiuredIfAttribute gives System.NullReferenceException. Because CommonUseInfo haven't got CommonUseStatus property. How can I use this Attribute in this way?
public class FoundationCode : SpatialEntity
{
   public bool CommonUseStatus {get; set;}
   public string FullFoundationCode { get; set; }
   public string ProvinceCode { get; set; }
   public string DistrictCode { get; set; }
   public bool FoundationOwner { get; set; }
   public virtual CommonUseInfo CommonUseInfo { get; set; }
}


public class CommonUseInfo : BaseEntity
{
   public int CommonUseSchool { get; set; }
   **[RequiredIfTrue("CommonUseStatus")]**
   public DateTime CommonUseStartingDate { get; set; }
   **[RequiredIfTrue("CommonUseStatus")]**
   public DateTime CommonUseEndDate { get; set; }
   public virtual FoundationCode FoundationCode { get; set; }
}