I'm trying to use ExpressiveAnnotations
to validate my form. I have two viewmodels wherein the 2nd model is dependent to the 1st model. Is this possible using this library?
Thank you.
public class ViewModel
{
[Required]
[Column(TypeName = "date")]
public DateTime? Start { get; set; }
[AssertThat("End >= Start", ErrorMessage = "You cannot set end date before the start of leave.")]
[Required]
[Column(TypeName = "date")]
[Display(Name = "End ")]
public DateTime? End { get; set; }
}
public class ViewModel1
{
[AssertThat("Date1 < Start", ErrorMessage = "Start cannot be before Date1.")]
[AssertThat("Date1 >= End", ErrorMessage = "Start cannot be after Date1.")]
[Required]
[Display(Name = "Date1 ")]
[Column(TypeName = "date")]
public DateTime? Date1 { get; set; }
}