Skip to content

Instantly share code, notes, and snippets.

@testfirstcoder
Created February 26, 2016 13:31
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 testfirstcoder/ce3f3c79b15ce3c28e66 to your computer and use it in GitHub Desktop.
Save testfirstcoder/ce3f3c79b15ce3c28e66 to your computer and use it in GitHub Desktop.
Get pattern from DataAnnotations.RegularExpressionAttribute
string GetRegularExpressionAttributePattern<T>(string property)
{
return typeof(T)
.GetProperty(property)
.GetCustomAttribute<RegularExpressionAttribute>()
.Pattern;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment