Date Validation with DataAnnotation

0

I wanted to know if I have validate whether the inserted date is larger or not than the current date using Annotation, or if I have to handle the same controller. If so, please provide an example.

    
asked by anonymous 13.11.2016 / 02:13

1 answer

4

You can do this by creating a class that is derived from RangeAttribute :

public class DateAttribute : RangeAttribute
{
    public DateAttribute()
      : base(typeof(DateTime), DateTime.Now.ToShortDateString(), DateTime.MaxValue.ToShortDateString()) { }
}

Font

    
13.11.2016 / 02:29