That validation config doesn't seem to make much sense to me. The field
accountNumber cannot be both int and string, so you have to use required
instead of requiredstring if you want to process the input as int. If you
want it as string, you have to use something else than the int validator,
possibly regex or fieldexpression validator. Also the validators for the
field should be inside the same < field > -tag so they can be
short-circuited. Try something like this (almost straight copy/paste from
the struts wiki pages):

<field name="accountNumber">
      <field-validator type="required" short-circuit="true">
          <message>You must enter a value for accountNumber.</message>
      </field-validator>
      <field-validator type="int">
          <para m name="min">6</param>
          <para m name="max">10</param>
          <message>bar must be between ${min} and ${max}, current
value is ${accountNumber}.</message>
      </field-validator>
</field>


On 8/8/07, orshoe <[EMAIL PROTECTED]> wrote:
>
>
> Hi all,
> I am trying to enforce a "requiredstring" on a text field and also make
> sure
> it follows certain constraints. I am using the following in the
> <action>-validation.xml:
>
> ---------------------------------------------------------------------------------------------------------------------------
> <validators>
>     <field name="accountNumber">
>         <field-validator type="int">
>                   <para m nam e="min">6</para m>
>                   <para m nam e="max">10</para m>
>             <message>Account Number cannot be less than ${min} or greater
> than ${max}. Its currently ${accountNumber}</message>
>         </field-validator>
>     </field>
>     <field name="accountNumber">
>         <field-validator type="requiredstring">
>             <message>You must enter Account Number</message>
>         </field-validator>
>     </field>
> </validators>
>
> ---------------------------------------------------------------------------------------------------------------------------
> The problem is, I am getting both the messages displayed (also the "You
> must
> enter Account Number") even when there is a value (say, 5) entered in the
> field. Is there any way to get only the appropriate message displayed
> based
> on the input.
> note: Please ignore the extra spaces in the param tags, I had
> intentionally
> added the space to make sure the message preview'd properly.
> --
> View this message in context:
> http://www.nabble.com/Struts-2-Validation-multiple-validators-on-same-field-tf4232748.html#a12042474
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to