Created
February 12, 2013 14:55
-
-
Save einarwh/4770394 to your computer and use it in GitHub Desktop.
Overview of the MkayAttribute.
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
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] | |
public class MkayAttribute : ValidationAttribute, IClientValidatable | |
{ | |
private readonly string _ruleSource; | |
private readonly string _defaultErrorMessage; | |
private readonly Lazy<ConsCell> _cell; | |
public MkayAttribute(string ruleSource) | |
{ | |
_ruleSource = ruleSource; | |
_defaultErrorMessage = "Respect '{0}', mkay?".With(ruleSource); | |
_cell = new Lazy<ConsCell>(() => new ExpParser(ruleSource).Parse()); | |
} | |
protected ConsCell Tree | |
{ | |
get { return _cell.Value; } | |
} | |
public IEnumerable<ModelClientValidationRule> GetClientValidationRules( | |
ModelMetadata metadata, ControllerContext context) ... | |
protected override ValidationResult IsValid( | |
object value, ValidationContext validationContext) ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment