RuleBuilder comparing DateFrom with Datetime.Now

与世无争的帅哥 提交于 2021-02-05 11:29:09

问题


I'm trying to validate a DateFrom field so that it's gives an error message whenever the user inputs the date before or equal to todays date. But somehow the method I'm using doesn't work (no error message is shown). Any suggestions? I'm required to use RuleBuilder and this is my first time using it.

My current code:

        RuleFor(x => x.DateFrom)
            .NotNull()
            .DataType(DataType.Date)
            .GreaterThanOrEqualTo(DateTime.Now)
            .WithMessage("Date To must be after Date From")
            .AdditionalMetadata("class", "dateInputFieldExtended")

来源:https://stackoverflow.com/questions/65410613/rulebuilder-comparing-datefrom-with-datetime-now

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!