You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by fea jabi <zy...@hotmail.com> on 2006/10/16 20:19:07 UTC
validwhen for double value comparision
Need to check if the value entered is greater than zero.
Tried the below using the validwhen
<field property="payment" depends="required,validwhen">
<msg name="required" key="error.required"/>
<msg name="validwhen" key="error.gtzero"/>
<var>
<var-name>test</var-name>
<var-value>(*this* > "0.00")</var-value>
</var>
</field>
validation seams to be working right when entered 0,0.00,any string, any
negative number all give validation error. which is exactly what I wanted.
Is this really doing the validation right i.e checking if the value entered
is greater than zero?
Is this the right way to do? or do I have to create the custom validator to
do double value comparision?
Thanks.
_________________________________________________________________
Use your PC to make calls at very low rates
https://voiceoam.pcs.v2s.live.com/partnerredirect.aspx
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: validwhen for double value comparision
Posted by Laurie Harper <la...@holoweb.net>.
fea jabi wrote:
> Need to check if the value entered is greater than zero.
>
> Tried the below using the validwhen
>
> <field property="payment" depends="required,validwhen">
> <msg name="required" key="error.required"/>
> <msg name="validwhen" key="error.gtzero"/>
> <var>
> <var-name>test</var-name>
> <var-value>(*this* > "0.00")</var-value>
> </var>
> </field>
>
> validation seams to be working right when entered 0,0.00,any string, any
> negative number all give validation error. which is exactly what I
> wanted. Is this really doing the validation right i.e checking if the
> value entered is greater than zero?
>
> Is this the right way to do? or do I have to create the custom validator
> to do double value comparision?
Well if what you have is giving you the right behaviour, it doesn't seem
like there's much need to write a custom validation rule :-) That said,
you may want to look at the provided float and double rules and/or the
floatRange and doubleRange rules. See the Validator Guide [1] for details.
L.
[1] http://struts.apache.org/1.2.9/userGuide/dev_validator.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org