Created
May 25, 2015 16:51
-
-
Save komainu85/3cf4313940bf32a522b6 to your computer and use it in GitHub Desktop.
Entity Service Validation Attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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