I’ve decided to rename the root class for the checks to “Bouncer” (http://en.wiktionary.org/wiki/bouncer : “A member of security personnel employed by bars, nightclubs, etc to maintain order and deal with patrons who cause trouble.”). To check all registered and attribute based rules of a parameter, one line of code per parameter is enough:
Bouncer.ForCheckData(() => customer).Assert();
Also you can now query the bouncer for rule violations without causing exceptions:
var res = Bouncer.ForMessages(() => saveBusinessObject).Assert(); foreach (var result in res.Results) Console.WriteLine(result);
The exceptions have been improved to include the name of the parameter and the name of the property of that object which causes the violation. A violation will now always create a “RuleValidationException” which inherits from “ArgumentException” (that way exception handlers catching “ArgumentException” will work, but you also can catch specificly the exceptions of rule violations).
The fluent interface has been improved, so you can now implement additional ways to check the rules – exception throwing and creation of a list of violations have been implemented, but possible you want just central logging of specific information. To do that, you need to
The functionality is now inside the Sem.Sync project under LGPL (you can freely use it in free and commercial products, but if you modify it, your modification is also bound to LGPL). A sample project also has been included.