I'm validating a form containing various types of data. One of the fields to be validated is an amount which must be between 0.01 and 999999.99.
The code for this field validation in the validation.xml is;
Expand|Select|Wrap|Line Numbers
- <field property="amount" depends="required,webxvalidator,floatRange">
- <arg0 key="label.authorization.txn.amount"/>
- <arg1 name="floatRange" key="${var:min}" resource="false"/>
- <arg2 name="floatRange" key="${var:max}" resource="false"/>
- <var><var-name>min</var-name><var-value>0.01</var-value></var>
- <var><var-name>max</var-name><var-value>999999.99</var-value></var>
- <var>
- <var-name>dataType</var-name>
- <var-value>amount</var-value>
- </var>
- </field>
Expand|Select|Wrap|Line Numbers
- <validator name="floatRange"
- classname="org.apache.struts.validator.FieldChecks"
- method="validateFloatRange"
- methodParams="java.lang.Object,
- org.apache.commons.validator.ValidatorAction,
- org.apache.commons.validator.Field,
- org.apache.struts.action.ActionMessages,
- javax.servlet.http.HttpServletRequest"
- depends="float"
- msg="errors.range"/>
But, a small range of numbers, which in this case is 1,000,000.00 to 1,000,000.03 will not flag up as being outside the range! This causes problems later as the value is accepted and is being used will being outside predefined ranges elsewere.
The same thing happens across the board if I lower the max variable to any value. The max+.01 to max+.04 will always be (incorrectly) accepted as within the range.
Has anyone seen this before? See anything blatent I'm doing wrong?
Any ideas would be grand.
Thank you,
Paul