I can not recall the exact instance where I felt something like that would be cool... but when I was coding something, I did feel something like that would be useful.
But let me cook up an example for you right now: Lets say I have a "Mode of Payment" dropdown which would let me select "CreditCard" or "Cheque". And next to it is the instrument identifier textbox. Now If I choose "CreditCard" option I want the Creditcard validation to kick in. Otherwise I want the cheque validation to kick in. As of today I can accomplish this only through regular expressions (if I am looking at declaritive style of validation with out writing my own validation rule classes). Another example could be: Country dropdown...If I choose "India" I want the date text box to accept date in the dd/mm/yy format. If "USA" is chosen, I want date to be chosen in the "mm/dd/yy" format. I think it should be useful to do some of these by leveraging on existing validation rules rather than re-write them. ~raghu On 12/6/05, Laurie Harper <[EMAIL PROTECTED]> wrote: > > So you're proposing a way for a 'validwhen' rule to be able to invoke > other validation rules (or control which of the validations specified by > the 'depends' value is actually enforced)? I actually think that could > be quite useful in some cases, but probably not very many. Can you think > of any concrete examples of where you'd use something like that? > > L. > > Raghu Kanchustambham wrote: > > That is correct .. but what would be more interesting and more useful is > to > > say "this should be in a date format when that text box is filled" or > > something of that sort. What I think validation f/w supports is > validwhen > > "co-exists" with other validation rules... but they are kind of > independent. > > I want to couple them .. "enforce this rule only when that control is in > > some state" kind of scenario with out using the regular expressions. > > > > Dont you think that brings in quite a bit of value and ease to using the > > validaror f/w? > > > > ~raghu > > > > > > On 12/6/05, Laurie Harper <[EMAIL PROTECTED]> wrote: > >> Well, you can use multiple validations, (including validwhen) together, > >> but if you do they all have to pass. So you can't, for example, use > >> validwhen to say a field can be empty if some other field isn't set, > but > >> must pass the 'date' validation otherwise. Not sure if that made sense > >> or not... > >> > >> L. > >> > >> Raghu Kanchustambham wrote: > >>> Just wondering Laurie ... why cant I use other "validation rules" > along > >> with > >>> validwhen? I dont see any fundamental reason why I need to resort to > >> regular > >>> expressions when I use validwhen tag. For example, it would be great > if > >> I > >>> could say .. validwhen (some test) .. use the date validation! > >>> > >>> Is there something inherent in the way it is designed that this is not > >>> possible? > >>> > >>> Regards, > >>> Raghu > >>> > >>> > >>> > >>> On 12/6/05, Laurie Harper <[EMAIL PROTECTED]> wrote: > >>>> I was going to say 'yes, you can do that,' but I don't think you can > >>>> express field length constraints with validwhen unfortunately :-( > >>>> > >>>> L. > >>>> > >>>> Deepa Khetan wrote: > >>>>> Actually, i need to implement a if{} else{} condition in validation > >>>>> framework.. > >>>>> if(field1=='usr1'){ > >>>>> <field > >>>>> property="password" > >>>>> depends="minlength,maxlength"> > >>>>> > >>>>> <var> > >>>>> <var-name>minlength</var-name> > >>>>> <var-value>8</var-value> > >>>>> </var> > >>>>> > >>>>> <var> > >>>>> <var-name>maxlength</var-name> > >>>>> <var-value>14</var-value> > >>>>> </var> > >>>>> </field> > >>>>> > >>>>> }else{ > >>>>> <field > >>>>> property="password" > >>>>> depends="minlength,maxlength"> > >>>>> > >>>>> <var> > >>>>> <var-name>minlength</var-name> > >>>>> <var-value>6</var-value> > >>>>> </var> > >>>>> > >>>>> <var> > >>>>> <var-name>maxlength</var-name> > >>>>> <var-value>11</var-value> > >>>>> </var> > >>>>> </field> > >>>>> } > >>>>> > >>>>> > >>>>> Something of the above sort... Can i do that with the frmework or do > i > >>>> need > >>>>> to write my own javascript?? > >>>>> Regards, > >>>>> Deepa > >>>>> > >>>>> On 12/5/05, Laurie Harper <[EMAIL PROTECTED]> wrote: > >>>>>> Wendy Smoak wrote: > >>>>>>> On 12/4/05, Deepa Khetan <[EMAIL PROTECTED] > wrote: > >>>>>>>> I need sme help with validator framework.. I have a LogonForm > which > >>>> is > >>>>>> being > >>>>>>>> mapped with 2 different JSPs. Both the JSPs have the password > >> field, > >>>>>> but the > >>>>>>>> validation for the field are diferent(The minlength and maxlength > >> for > >>>>>> both > >>>>>>>> the pages is different). On the basis of the value of some other > >>>>>> field(say, > >>>>>>>> field1) i need to validate the pasword field. How can i do this?? > >>>>>>> You can use one of the form bean types with 'Action' in the name, > >> such > >>>>>>> as ValidatorActionForm. > >>>>>>> > >> > http://struts.apache.org/struts-doc-1.2.7/api/org/apache/struts/validator/ValidatorActionForm.html > >>>>>>> These are mapped by path instead of form bean name, so you can > have > >> a > >>>>>>> different set of rules for each action mapping. > >>>>>>> > >>>>>>> In validation.xml, you might have: > >>>>>>> <form name="/register"> > >>>>>>> which matches up with (from struts-config.xml) > >>>>>>> <action path="/register" ... > > >>>>>>> > >>>>>>> HTH, > >>>>>>> -- > >>>>>>> Wendy > >>>>>> The other thing you might want to look at is the 'validwhen' rule > >> [1], > >>>>>> if you want to base your validation criteria on the value of field1 > >>>>>> rather than on the action mapping path. > >>>>>> > >>>>>> L. > >>>>>> > >>>>>> [1] > >>>>>> > >>>>>> > >> > http://struts.apache.org/struts-doc-1.2.7/userGuide/dev_validator.html#validwhen > >>>>>> > --------------------------------------------------------------------- > >>>>>> To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>>>> For additional commands, e-mail: [EMAIL PROTECTED] > >>>>>> > >>>>>> > >>>> --------------------------------------------------------------------- > >>>> To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>> For additional commands, e-mail: [EMAIL PROTECTED] > >>>> > >>>> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >