You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Christoph Kutzinski <ku...@gmx.de> on 2004/07/26 11:36:55 UTC

Select Validation Rules based on context?

Hi,

I like to know if someone has successfully used the validation framework 
to select rules based on a "free" context.
My problem is this:

I have a registration wizard for a product that has different variants 
(for individuals, for companies, ...)
Now I want to reuse the wizard's JSPs, ActionForm, Action for the 
different variants since they are 90% equal.
However there are some differences (e.g. individual has a required field 
Birthday while companies have not).
How do I tell the validation framework to choose the validation rule for 
birthday only if the variant is "indidual"?

BTW: While I could handle the situation above by filling birthday for 
comapnies with a dummy value, it will fail if I have completely 
differing validation rules for the different variants.
E.g.: companies may choose a freely choosable email address while 
individuals have to put a separator (dot) in the mail local part 
(first.last@domain.com)


thanx
Christoph

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Select Validation Rules based on context?

Posted by Bill Siggelkow <bi...@bellsouth.net>.
If you are using Struts 1.1 you may be able to use the "requiredIf" rule 
-- if you are using Struts 1.2 you can use the more powerful and easier 
to use "validWhen" rule. Details can be found at 
http://struts.apache.org/userGuide/dev_validator.html.

Christoph Kutzinski wrote:
> Hi,
> 
> I like to know if someone has successfully used the validation framework 
> to select rules based on a "free" context.
> My problem is this:
> 
> I have a registration wizard for a product that has different variants 
> (for individuals, for companies, ...)
> Now I want to reuse the wizard's JSPs, ActionForm, Action for the 
> different variants since they are 90% equal.
> However there are some differences (e.g. individual has a required field 
> Birthday while companies have not).
> How do I tell the validation framework to choose the validation rule for 
> birthday only if the variant is "indidual"?
> 
> BTW: While I could handle the situation above by filling birthday for 
> comapnies with a dummy value, it will fail if I have completely 
> differing validation rules for the different variants.
> E.g.: companies may choose a freely choosable email address while 
> individuals have to put a separator (dot) in the mail local part 
> (first.last@domain.com)
> 
> 
> thanx
> Christoph


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org