using System.Collections.Generic;
using System.Web.Mvc;

namespace TestDatePickerValidation
{
    public class WorkDayValidator : DataAnnotationsModelValidator<WorkDayAttribute>
    {
        private readonly string _message;

        public WorkDayValidator(
            ModelMetadata metadata, 
            ControllerContext context, 
            WorkDayAttribute attribute) : base(metadata, context, attribute)
        {
            _message = attribute.ErrorMessage;
        }

        public override IEnumerable<ModelClientValidationRule> GetClientValidationRules()
        {
            var rule = new ModelClientValidationRule
                           {
                               ErrorMessage = _message,
                               ValidationType = "workday"
                           };

            return new[] { rule }; 
        }
    }
}
