Aug 7, 2010 at 10:39 AM
Edited Aug 7, 2010 at 11:22 AM
Thank you for using Conditions. About your suggestion about validating strings the following:
The validation methods for strings contain an overload that accepts a System.StringComparison enum, that allows you to exactly specify how the strings must be compared. You can ignore the case be writing the following:
Condition.Requires(str, "str").StartWith("abc", StringComparison.OrdinalIgnoreCase);
While it is a more verbose than using a boolean, it in fact does a better job in describing its intent. I hope this works for you.
About you suggestion about the generic validator, the following:
The framework currently contains several overloads named 'Evaluate` that do exactly this. There's an overload excepting a boolean, and there is an overload excepting an Expression<Func<T, bool>> (a lambda). Here are two examples:
Condition.Requires(str, "str").Evaluate(s => s == null || s.Length > 100);
Condition.Requires(str, "str").Evaluate(s == null || s.Length > 100, "Value should xxx");
I hope this works for you.
If there are any questions about this, or other suggestions, please keep them coming.