Created
March 8, 2016 15:13
-
-
Save JoeStead/90da76bbacac331e3a86 to your computer and use it in GitHub Desktop.
Generates some docs stuff for fluent validation
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
public void Stuff() | |
{ | |
var what = AllRules(); | |
foreach (var s in what) | |
{ | |
Debug.WriteLine(s); | |
} | |
} | |
public List<string> AllRules() | |
{ | |
var descriptor = this.CreateDescriptor(); | |
return (from member in descriptor.GetMembersWithValidators() | |
from validationRule in descriptor.GetRulesForMember(member.Key) | |
select (PropertyRule) validationRule | |
into rule | |
from validator in rule.Validators | |
select $"validation type:{validator.ToString().Replace("FluentValidation.Validators.", "")} " + | |
$"| property:{rule.PropertyName} " + | |
$"| type:{rule.Member.ToString().Split(' ').FirstOrDefault()} " + | |
$"| Regex:{(validator as RegularExpressionValidator)?.Expression}").ToList(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment