Validate DateTime with FluentValidator

前端 未结 4 710
情书的邮戳
情书的邮戳 2020-12-31 02:25

This is my ViewModel class:

public class CreatePersonModel
{
    public string Name { get; set; }
    public DateTime DateBirth { get; set;          


        
4条回答
  •  一生所求
    2020-12-31 02:49

    Try this one

    RuleFor(f =>
            f.StartDate).Cascade(CascadeMode.StopOnFirstFailure).NotEmpty()
                        .Must(date => date != default(DateTime))
                        .WithMessage("Start date is required");
    

提交回复
热议问题