title: Centralizing Regular Expression Validation Patterns in ASP.Net MVC
body: <p>I there a way in ASP.Net MVC to have a RegularExpression attribute on a model property to pull the pattern string property from resource file or another class?</p>
  
  <p>When I attempt to use another class I get a message stating that the attribute values must be a constant, typeof expression, or an array.</p>
  
  <p>Ultimately, I'm attempting to abstract some of these patterns so I don't have to update multiple files if a bug is located in a pattern.</p>
  
  <h2>Example:</h2>
  
  <pre><code>public class MyModel{
      [RegularExpression(StaticPatternClass.EmailPattern, ErrorMessage="invalid email")]
      public string email { get; set;}
  }
  
  public static class StaticPatternClass{
      public static string EmailPattern = @"My pattern here";
  }
  </code></pre>