Error Level

Jul 7, 2009 at 1:21 PM

Continuing with my ideas, I wondered if the erros could have severity levels, just like the VS that has Errors and Warnings.

Then the user could use the warning to show an message but not prevent the program to continue.

Jul 21, 2009 at 3:14 PM

I guess we could have an enum for that and it's just another field in ValidatorResult. So not too hard to add. Maybe some interface for setting it looks like:

Validate.That(foo, "foo").IsGreaterThan(0).WarnIf().IsLessThan(5);

Which means it's an error for the first one, and a warning only if it's the second one that doesn't match.

Probably a fairly small addition. What do you think?


Jul 21, 2009 at 3:23 PM

The WarnIf will work just like the not works. You're a genius!

Jul 22, 2009 at 3:17 PM

Actually, since you specify what you expect, it wants to be WarnUnless otherwise it reads very confusingly. Anyway, I just checked in an initial patch that implements this, and also some unit tests. Needs more tests...but see what you think.