0

安装foolproof.core后,我在模型数据表示法上使用了GreaterThan,但是当我在returndate上插入一个小于初始日期的日期时间时,没有显示错误消息。我必须使用服务配置还是有什么问题。我不能'没有获得关于如何在 asp.net 核心 mvc 应用程序上使用万无一失的完整文档。

模型

    [GreaterThan("InitialDate", ErrorMessage = "Insert Return Date greater than Initial Date!!!")]
    [DisplayName("Return Date")]
    [Required(ErrorMessage = "Insert Return Date!!!")]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
    public DateTime? ReturnDate { get; set; }

    [GreaterThan("requestDate", ErrorMessage = "Insert Initial Date greater than Request Date!!!")]
    [DisplayName("Initial Date")]
    [Required(ErrorMessage = "Insert Initial Date!!!")]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
    public DateTime? InitialDate { get; set; } 
4

1 回答 1

0

您必须在 startup.cs ConfigureServices 方法中注册 FoolProof

public override void ConfigureServices(IServiceCollection services)
{           
    ...

    services.AddFoolProof();
}
于 2020-08-27T09:39:24.127 回答