Files
MileageTraker/Web/Attributes/DenyFutureDateAttribute.cs
2014-02-02 10:19:02 -05:00

16 lines
367 B
C#

using System;
using System.ComponentModel.DataAnnotations;
namespace MileageTraker.Web.Attributes
{
public class DenyFutureDateAttribute : ValidationAttribute
{
public override bool IsValid(object value)
{
DateTime date;
if(value == null || !DateTime.TryParse(value.ToString(), out date))
return false;
return date.Date <= DateTime.Today;
}
}
}