yep validation like that definately should be done with an object and a
collection.

Like you say, have a ValidationList class, and .addValidationFail() method
that accumulates it. Exceptions generally are best avoided unless there is
something seriously wrong. This is analagous to web frameworks where they
have .addError() methods (like in struts for an unpleasant example).

On 1/30/06, Paul Smith <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I maybe missing something fairly basic here but what I'm trying to do
> is have some of my rules throw an exception when the condition is true
> but I want to be able to stack those exceptions and return them all to
> be iterated through. Currently I only get one exception back which
> will basically be whichever rule is fired first. The only way I can
> think of doing this is instead of throwing the exception, add it to a
> list in the application data, then when I return from the rules
> engine, get that list from the application data and throw it back to
> the client. The example scenario is as follows:
>
> I want to be able to validate say an address but have each validation
> failure point as an exception and the list of exception messages then
> displayed to the client. eg) The user didn't set the postcode and the
> street number. The two validation exceptions are "Must enter a
> postcode" and "Must enter a street address". Each validation rule
> throws a ValidationException with a key and a message.
>
> Is this the way to do it or not?
>
> Regards
>
> Paul
>

Reply via email to