Data Annotation Ranges of Dates

后端 未结 7 1342
故里飘歌
故里飘歌 2020-12-08 18:53

Is it possible to use [Range] annotation for dates?

something like

[Range(typeof(DateTime), DateTime.MinValue.ToString(), DateTime.To         


        
相关标签:
7条回答
  • 2020-12-08 19:21

    Docs on MSDN says you can use the RangeAttribute

    [Range(typeof(DateTime), "1/2/2004", "3/4/2004",
            ErrorMessage = "Value for {0} must be between {1} and {2}")]
    public datetime Something { get; set;}
    
    0 讨论(0)
提交回复
热议问题