Custom model validation of dependent properties using Data Annotations

后端 未结 5 1077
迷失自我
迷失自我 2020-11-27 03:30

Since now I\'ve used the excellent FluentValidation library to validate my model classes. In web applications I use it in conjunction with the jquery.validate plugin to per

5条回答
  •  生来不讨喜
    2020-11-27 04:24

    I had this very problem and recently open sourced my solution: http://foolproof.codeplex.com/

    Foolproof's solution to the example above would be:

    public class Event
    {
        [Required]
        public DateTime? StartDate { get; set; }
    
        [Required]
        [GreaterThan("StartDate")]
        public DateTime? EndDate { get; set; }
    }
    

提交回复
热议问题