1
如果我有像一個視圖模型屬性:爲什麼MVC FluentValidation InclusiveBetween總是會引發DateTime錯誤?
[DataType(DataType.DateTime)]
public DateTime? MyDate{ get; set; }
而且這樣的驗證規則:
public class YourDetailsViewModelValidator : AbstractValidator<YourDetailsViewModel>
{
public YourDetailsViewModelValidator()
{
RuleFor(x => x.MyDate)
.InclusiveBetween(startDate, endDate)
.WithMessage("error");
}
}
爲什麼會出現錯誤火不管什麼日期輸入?
我確實看到類似的事情發生enter link description here但答案最終被接受,所以我希望它可以正常工作。
您是否在客戶端或服務器端說過失敗,並且您檢查了值綁定是否正確?其在客戶端上是 –
。這一切似乎都受到了妥善的約束。 – davy