Suggested feature

Topics: Developer Forum
Jan 29, 2007 at 2:55 PM
I think this would be nice to have:
If a property (or parameter) has several rules amongst a Required one that fails, the validator could ignore the other rules.
Jan 30, 2007 at 11:14 AM
I am a little confused. Are you saying that if one rule fails the framework should not attempt to process the remaining rules? For performance reasons?

A scenario where this would be used might help clear up my confusion.
Jan 31, 2007 at 10:23 AM
No, no way I would mean that. On the contrary, I think running all the rules and stacking up all the results is one of the very basic requirements of any validation framework.
What I meant was pretty much like the ASP.NET validators work, for example if you have a textbox with a asp:RegularExpressionValidator on it with some expression, if you leave the textbox blank and post the form it will not raise a validation error (because that is what a required validator would do) and also if you had both a asp:RegularExpressionValidator and a asp:RequiredFieldValidator on the textbox and you would leave it empty you would only get the required validation error.
However, on a second thought I don't think this has to be part of the validation framework as this can be easily dealt with from the code using the framework.

Jan 31, 2007 at 11:51 AM
Edited Jan 31, 2007 at 11:52 AM

String is an interesting one because it can be null, an empty string or a non empty string.
Currently if you have a RequiredStringRule and a RegexRule on a string property the following happens
-Property is null
RequiredStringRule validates to false
RegexRule validates to true (isn’t this what you are asking for?).
-Property is empty string
RequiredStringRule validates to false
RegexRule validates as defined by the regular expression.
-Property is a non empty string
RequiredStringRule validates to true
RegexRule validates as defined by the regular expression.