struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject [S1] Validator does not respect locale when validating double value?
Date Fri, 18 Jan 2013 18:02:21 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

All,

I'm running Struts 1.3.10 (with commons-validator 1.3.1), and I'm
trying to validate (and subsequently parse) a floating-point value as
a double.

My validator configuration looks like this (I apologize for it's
potential unreadability):

      <field property="maxAgeMonths"
	    page="3"
            depends="required,maxlength,double,doubleRange">
	<arg position="1" name="maxlength" key="${var:maxlength}"
resource="false" />
    <var><var-name>maxlength</var-name><var-value>8</var-value></var>
	<var><var-name>min</var-name><var-value>-10.0</var-value></var>
	<var><var-name>max</var-name><var-value>11.99</var-value></var>
	<msg name="doubleRange" bundle="Staff" key="error.age-out-of-range" />
      </field>

In my session, the value of org.apache.struts.action.LOCALE is "es",
so Spanish. My UI is coming-up in Spanish, too.

When I try to submit "3,77" as the "max age", I get a message that the
field value is not a valid "double".

If I change the value to "3.77", I get no errors, and of course my
code (somewhat) correctly parses the value to 377 months because, in
Spanish, the period means a grouping separator and not a decimal point.

I have not altered the standard definition of the "double" validator:
I'm using whatever comes in
/org/apache/struts/validator/validator-rules.xml.

Before I go digging-through the code Struts/commons-validator to find
out exactly what might be wrong, can anyone give me any suggestions at
to what I might be missing?

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlD5ji0ACgkQ9CaO5/Lv0PAMmACfWNa2HW7HZbcZpttLjNzHfZXk
R8cAn1+cSyS2l85kXndju57zz037OBmE
=Kpsg
-----END PGP SIGNATURE-----

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


Mime
View raw message