Ejemplo n.º 1
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (value == null)
            {
                return(null);
            }

            var date     = (DateTime)value;
            var isLegacy = ((ModelBase)validationContext.ObjectInstance).IsLegacy;

            if (date < _startDate && isLegacy == false)
            {
                return(new ValidationResult(ErrorMessage));
            }
            if (date > DateTime.Today)
            {
                return(new ValidationResult(ValidationMessages.TodayOrEarlier(validationContext.DisplayName)));
            }
            return(null);
        }
Ejemplo n.º 2
0
 public override string FormatErrorMessage(string name)
 {
     return(ValidationMessages.DateValidityRangeStart(name, _startDate.ToShortDateString()));
 }