using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.Contracts;

namespace TestDatePickerValidation
{
    public class WorkDayAttribute : ValidationAttribute
    {
        public override bool IsValid(object value)
        {
            Contract.Requires(value != null);

            DateTime datetime = (DateTime) value;
            if (datetime.DayOfWeek == DayOfWeek.Saturday || datetime.DayOfWeek == DayOfWeek.Sunday)
            {
                return false;
            }

            return true;
        }
    }
}
