Hi Victor,

I don't have an explicit example but were I to have to do this I would use a validwhen validation that would look something like:

<field property="blah" depends="validwhen">
 <arg position="0" key="blah.label"/>
 <var>
   <var-name>test</var-name>
   <var-value>((*this* < 10) or (*this* > 100))</var-value>
 </var>
</field>

You can find out more details on validwhen in the validator developers guide: http://struts.apache.org/struts-taglib/dev_validator.html

Regards,

Bart.

Victor Ying wrote:
Hi Bart,
   Thanks for the information, my main questions how
do you validate open interval like (0,10) in float
field.do you have example for that?
   Thanks
---victor

--- Bart Busschots <[EMAIL PROTECTED]> wrote:

Hi Victor,

The key to the validator is that you can use
multiple validations on the one filed so you can combine things like less than and more than to give you an open range etc. Another very powerful validation is 'valid when' which allows you to set up complex checks that related to other fields in your input etc.

Below is and example of the validation I use on a
password changing form where the confirmation must obviously be equal to the first entry of the new password:

  <form name="changePasswordForm">
   <field property="passwordCurrent"
depends="required">
    <arg0
key="login.changePassword.currentPassword.label"/>
   </field>
   <field property="passwordNew" depends="required,
minlength">
    <arg0
key="login.changePassword.newPassword.label"/>
    <arg1 name="minlength" key="${var:minlength}"
resource="false"/>
<var><var-name>minlength</var-name><var-value>6</var-value></var>
   </field>
   <field property="passwordNewVerify"
depends="validwhen">
    <arg0
key="login.changePassword.newPwsNotEqual"/>
    <var>
     <var-name>test</var-name>
     <var-value>(*this* == passwordNew)</var-value>
    </var>
   </field>
  </form>

You can also see in the above example that
passwordNew uses two validations, required and minlength.

Hope that is of some help,

Bart.

victor ying wrote:
Hi All,
     I am using struts 1.2.7 and related Apache
commons validator. I am using validation.xml(whose
rules are defined by validator-rules.xml
  I need your insight of following issues
  1.How do I validate open set data range,e,g
(1,10) where 1 and 10 are exclusive, current
intRange/floatRange valiation only support close set
data range validation where bounds are included?
  2.I find a limitation of common validator. i.e
if I enter +1000 in a field that has "integer"
validation turned on, the common validator will
complain about this field is NOT integer something
like that. Is this a bug?
  3.A more complicated scenario, suppose that I
need to validator two fields,say x and y, the data
range of y is dependent on x, e.g y must be the
range of [x,100], how do I make use of the common
validator to do that? I know I can write my
customized plugged in validator to do it, but does
validator provides a default way to do it?
  Many thanks in advance!
--Victor

                
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone
Calls to the US (and 30+ countries) for 2ยข/min or
less.

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




__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to