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 2003/12/12 16:06:08 UTC

DO NOT REPLY [Bug 25478] New: - the validator framework does not take locale into account for validating floats

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

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25478

the validator framework does not take locale into account for validating floats

           Summary: the validator framework does not take locale into
                    account for validating floats
           Product: Struts
           Version: 1.1 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Validator Framework
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: stanpinte@fastmail.fm


the validator framework does not take locale into account for validating floats

and it is normal: 


    /**
     * Checks if the value can safely be converted to a float primitive.
     *
     * @param value The value validation is being performed on.
     */
    public static Float formatFloat(String value) {
        if (value == null) {
            return null;
        }
        try {
            return new Float(value);
        } catch(NumberFormatException e) {
            return null;
        }
    }

this piece of code is a snippet from the Validator GenericTypeValidator class, 
which doesn't use the locale. --> when users use a different locale than the 
server default locale, it fails:

If I use a "fr" locale, and enters "2,6", it is not recognized as a float, and 
an exception is thrown.

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