我正在尝试使用ExpressiveAnnotations
来验证我的表单。我有两个视图模型,其中第二模型依赖于第一模型。这可以使用这个库吗?
谢谢。
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; }
}