You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2004/12/29 13:37:51 UTC

DO NOT REPLY [Bug 32875] New: - Unable to do validwhen comparisons of doubles.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32875>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32875

           Summary: Unable to do validwhen comparisons of doubles.
           Product: Struts
           Version: 1.2.6 Beta
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Keywords: PatchAvailable
          Severity: normal
          Priority: P2
         Component: Validator Framework
        AssignedTo: dev@struts.apache.org
        ReportedBy: nminshew@gmail.com


I ran into a problem this week where validwhen wasn't working correctly when
trying to compare 2 doubles.  I have 2 fields, one a minimum value and the other
a maximum value.  I setup in the validation.xml this validator dependency:

<field property="sizeHeightMin" depends="required, double" >
    <arg0 key="displayName.sizeHeightMin" />
    <msg name="double" key="errors.numeric" />
</field>
<field property="sizeHeightMax" depends="required, double, validwhen" >
    <arg0 key="displayName.sizeHeightMax" />
    <arg1 key="displayName.sizeHeightMin" />
    <msg name="double" key="errors.numeric" />
    <msg name="validwhen" key="errors.range" />
    <var>
        <var-name>test</var-name>
        <var-value>(*this* > sizeHeightMin)</var-value>
    </var>
</field>

But when I would enter 6.5 for the min and 11.5 for the max it would fail
validation saying that the max was less than the min.  After debugging and
tracking down the problem I discovered that the evaluateComparison(Object,
Object, Object) method in ValidWhenParser.class was only checking to see if the
values were integers and if not doing a string comparison, thus the reason I was
getting the validation failure.  Also in that method it does a check to see if
the objects passed in are of type Integer.class.  Unless I'm missing something I
don't believe that will ever happen since in ValidWhen.class and in the field
method of ValidWhenParser.class you retrieve the value with
ValidatorUtils.getValueAsString(bean, property), thus the value will always be a
string.  I have added a patch for this issue and will be sending it in.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org