-Adam,

I've just changed my conf like that :

           <field property="enterpriseName"
               depends="validwhen">
               <arg0 key="error.inscription.entreprise.nom" />
               <var>
                   <var-name>test</var-name>
                   <var-value>(subscriptionType>=1)</var-value>
               </var>
           </field>

but, it still does not work..

On 7/25/06, Adam Gordon <[EMAIL PROTECTED]> wrote:

Jeremy-

At first glance, I think you need to modify your parenthesis.  Per the
Validation docs at
http://struts.apache.org/1.2.9/userGuide/dev_validator.html, only two
items may be joined with "and" or "or."  I don't know if that means you
can only have a max of two items or a max of two items per parends...

Secondly, I had a bunch of problems with "validwhen" and finally
resorted to implementing my own solution in my ValidatorForm's
validate(...) method because it appears that 'validwhen' is rather
basic.  It basically says "field A is valid when..."  In my experience,
"validwhen" doesn't chain well with other validation rules.

Alternatively, you could rewrite your rules to say:  ((subscriptionType
>= 2) and (subscriptionType &lt;= 4)).  Note the &lt;, you'll get
errors if you use a < character.  I assume you validate that
subscriptionType is an integer on [1,4].  Also, you don't need quotes
around the numbers.  Struts is smart enough to try numbers first and
then if that doesn't work, it resorts to Strings.  Besides, I'm not sure
the functionality you want is to compare Strings using inequalities...

Hope this helps.

-Adam

Jeremy Jardin wrote:
> Hi,
>
> I'm trying to use struts plugin validator to check a big form.. and it
> works
> well.. but I've a little pb with validwhen constraint;
>
> I've written something like this :
>
>            <field property="enterpriseName"
>                depends="validwhen">
>                <arg0 key="error.inscription.entreprise.nom" />
>                <var>
>                    <var-name>test</var-name>
>                    <var-value>((subscriptionType=="2")or
> (subscriptionType=="3")or(subscriptionType=="4"))</var-value>
>                </var>
>            </field>
>
> I just want to check the field 'enterpriseName' is not empty when I
> submit,
> but only if my select field 'subscriptionType" is more than 1. (2,3 or4)
>
> It does not work.
>
> why ??
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
~ jebmail ~

Reply via email to