Skip to content

Instantly share code, notes, and snippets.

@komainu85
Created May 25, 2015 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komainu85/3cf4313940bf32a522b6 to your computer and use it in GitHub Desktop.
Save komainu85/3cf4313940bf32a522b6 to your computer and use it in GitHub Desktop.
Entity Service Validation Attribute
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace MikeRobbins.EntityServiceDemo.Attributes
{
public class NotPastDateAttribute : ValidationAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
DateTime dateProperty = (DateTime)value;
DateTime dateNow = DateTime.Now;
return dateProperty >= dateNow ? ValidationResult.Success : new ValidationResult(ErrorMessage);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment