Author: mrdon Date: Mon Apr 25 23:15:17 2005 New Revision: 164749 URL: http://svn.apache.org/viewcvs?rev=164749&view=rev Log: Adding methods that use the locale for parsing numbers. The original patch came from Andrew van der Voort. Including unit tests however they could use more tests as I have limited knowledge of international number formats. PR: 21282 and 34198
Also adding a more clear error message when the validation method cannot be found. Modified: jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/GenericTypeValidator.java jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/ValidatorAction.java jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/TestTypeValidator.java jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/TypeTest.java jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-type.xml Modified: jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/GenericTypeValidator.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/GenericTypeValidator.java?rev=164749&r1=164748&r2=164749&view=diff ============================================================================== --- jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/GenericTypeValidator.java (original) +++ jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/GenericTypeValidator.java Mon Apr 25 23:15:17 2005 @@ -18,7 +18,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.commons.validator; import java.io.Serializable; @@ -26,22 +25,25 @@ import java.util.Locale; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.text.NumberFormat; import java.text.ParseException; +import java.text.ParsePosition; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** - * This class contains basic methods for performing validations that return the - * correctly typed class based on the validation performed. + * This class contains basic methods for performing validations that return the + * correctly typed class based on the validation performed. */ public class GenericTypeValidator implements Serializable { - - private static final Log log = LogFactory.getLog(GenericTypeValidator.class); + + private final static Log log = LogFactory.getLog(GenericTypeValidator.class); /** - * Checks if the value can safely be converted to a byte primitive. + * Checks if the value can safely be converted to a byte primitive. * - * @param value The value validation is being performed on. + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] */ public static Byte formatByte(String value) { if (value == null) { @@ -50,16 +52,50 @@ try { return new Byte(value); - } catch(NumberFormatException e) { + } catch (NumberFormatException e) { return null; } } /** - * Checks if the value can safely be converted to a short primitive. + * Checks if the value can safely be converted to a byte primitive. * - * @param value The value validation is being performed on. + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] locale The locale to use to parse the number (system default if + * null) + [EMAIL PROTECTED] + */ + public static Byte formatByte(String value, Locale locale) { + Byte result = null; + + if (value != null) { + NumberFormat formatter = null; + if (locale != null) { + formatter = NumberFormat.getIntegerInstance(locale); + } else { + formatter = NumberFormat.getIntegerInstance(Locale.getDefault()); + } + ParsePosition pos = new ParsePosition(0); + Number num = formatter.parse(value, pos); + + // If there was no error and we used the whole string + if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length()) { + if (num.doubleValue() >= Byte.MIN_VALUE && + num.doubleValue() <= Byte.MAX_VALUE) { + result = new Byte(num.byteValue()); + } + } + } + + return result; + } + + /** + * Checks if the value can safely be converted to a short primitive. + * + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] */ public static Short formatShort(String value) { if (value == null) { @@ -68,16 +104,50 @@ try { return new Short(value); - } catch(NumberFormatException e) { + } catch (NumberFormatException e) { return null; } } /** - * Checks if the value can safely be converted to a int primitive. + * Checks if the value can safely be converted to a short primitive. * - * @param value The value validation is being performed on. + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] locale The locale to use to parse the number (system default if + * null)vv + [EMAIL PROTECTED] + */ + public static Short formatShort(String value, Locale locale) { + Short result = null; + + if (value != null) { + NumberFormat formatter = null; + if (locale != null) { + formatter = NumberFormat.getIntegerInstance(locale); + } else { + formatter = NumberFormat.getIntegerInstance(Locale.getDefault()); + } + ParsePosition pos = new ParsePosition(0); + Number num = formatter.parse(value, pos); + + // If there was no error and we used the whole string + if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length()) { + if (num.doubleValue() >= Short.MIN_VALUE && + num.doubleValue() <= Short.MAX_VALUE) { + result = new Short(num.shortValue()); + } + } + } + + return result; + } + + /** + * Checks if the value can safely be converted to a int primitive. + * + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] */ public static Integer formatInt(String value) { if (value == null) { @@ -86,16 +156,50 @@ try { return new Integer(value); - } catch(NumberFormatException e) { + } catch (NumberFormatException e) { return null; } } /** - * Checks if the value can safely be converted to a long primitive. + * Checks if the value can safely be converted to an int primitive. + * + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] locale The locale to use to parse the number (system default if + * null) + [EMAIL PROTECTED] + */ + public static Integer formatInt(String value, Locale locale) { + Integer result = null; + + if (value != null) { + NumberFormat formatter = null; + if (locale != null) { + formatter = NumberFormat.getIntegerInstance(locale); + } else { + formatter = NumberFormat.getIntegerInstance(Locale.getDefault()); + } + ParsePosition pos = new ParsePosition(0); + Number num = formatter.parse(value, pos); + + // If there was no error and we used the whole string + if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length()) { + if (num.doubleValue() >= Integer.MIN_VALUE && + num.doubleValue() <= Integer.MAX_VALUE) { + result = new Integer(num.intValue()); + } + } + } + + return result; + } + + /** + * Checks if the value can safely be converted to a long primitive. * - * @param value The value validation is being performed on. + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] */ public static Long formatLong(String value) { if (value == null) { @@ -104,16 +208,50 @@ try { return new Long(value); - } catch(NumberFormatException e) { + } catch (NumberFormatException e) { return null; } } /** - * Checks if the value can safely be converted to a float primitive. + * Checks if the value can safely be converted to a long primitive. + * + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] locale The locale to use to parse the number (system default if + * null) + [EMAIL PROTECTED] + */ + public static Long formatLong(String value, Locale locale) { + Long result = null; + + if (value != null) { + NumberFormat formatter = null; + if (locale != null) { + formatter = NumberFormat.getIntegerInstance(locale); + } else { + formatter = NumberFormat.getIntegerInstance(Locale.getDefault()); + } + ParsePosition pos = new ParsePosition(0); + Number num = formatter.parse(value, pos); + + // If there was no error and we used the whole string + if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length()) { + if (num.doubleValue() >= Long.MIN_VALUE && + num.doubleValue() <= Long.MAX_VALUE) { + result = new Long(num.longValue()); + } + } + } + + return result; + } + + /** + * Checks if the value can safely be converted to a float primitive. * - * @param value The value validation is being performed on. + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] */ public static Float formatFloat(String value) { if (value == null) { @@ -122,16 +260,50 @@ try { return new Float(value); - } catch(NumberFormatException e) { + } catch (NumberFormatException e) { return null; } } /** - * Checks if the value can safely be converted to a double primitive. + * Checks if the value can safely be converted to a float primitive. * - * @param value The value validation is being performed on. + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] locale The locale to use to parse the number (system default if + * null) + [EMAIL PROTECTED] + */ + public static Float formatFloat(String value, Locale locale) { + Float result = null; + + if (value != null) { + NumberFormat formatter = null; + if (locale != null) { + formatter = NumberFormat.getInstance(locale); + } else { + formatter = NumberFormat.getInstance(Locale.getDefault()); + } + ParsePosition pos = new ParsePosition(0); + Number num = formatter.parse(value, pos); + + // If there was no error and we used the whole string + if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length()) { + if (num.doubleValue() >= (Float.MIN_VALUE * -1) && + num.doubleValue() <= Float.MAX_VALUE) { + result = new Float(num.floatValue()); + } + } + } + + return result; + } + + /** + * Checks if the value can safely be converted to a double primitive. + * + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] */ public static Double formatDouble(String value) { if (value == null) { @@ -140,19 +312,56 @@ try { return new Double(value); - } catch(NumberFormatException e) { + } catch (NumberFormatException e) { return null; } } /** - * <p>Checks if the field is a valid date. The <code>Locale</code> is - * used with <code>java.text.DateFormat</code>. The setLenient method - * is set to <code>false</code> for all.</p> + * Checks if the value can safely be converted to a double primitive. + * + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] locale The locale to use to parse the number (system default if + * null)vvv + [EMAIL PROTECTED] + */ + public static Double formatDouble(String value, Locale locale) { + Double result = null; + + if (value != null) { + NumberFormat formatter = null; + if (locale != null) { + formatter = NumberFormat.getInstance(locale); + } else { + formatter = NumberFormat.getInstance(Locale.getDefault()); + } + ParsePosition pos = new ParsePosition(0); + Number num = formatter.parse(value, pos); + + // If there was no error and we used the whole string + if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length()) { + if (num.doubleValue() >= (Double.MIN_VALUE * -1) && + num.doubleValue() <= Double.MAX_VALUE) { + result = new Double(num.doubleValue()); + } + } + } + + return result; + } + + /** + * <p> + * + * Checks if the field is a valid date. The <code>Locale</code> is used + * with <code>java.text.DateFormat</code>. The setLenient method is set to + * <code>false</code> for all.</p> * - * @param value The value validation is being performed on. - * @param locale The Locale to use to parse the date (system default if null) + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] locale The Locale to use to parse the date (system default if + * null) + [EMAIL PROTECTED] */ public static Date formatDate(String value, Locale locale) { Date date = null; @@ -165,18 +374,18 @@ DateFormat formatter = null; if (locale != null) { formatter = - DateFormat.getDateInstance(DateFormat.SHORT, locale); + DateFormat.getDateInstance(DateFormat.SHORT, locale); } else { formatter = - DateFormat.getDateInstance( - DateFormat.SHORT, - Locale.getDefault()); + DateFormat.getDateInstance( + DateFormat.SHORT, + Locale.getDefault()); } formatter.setLenient(false); date = formatter.parse(value); - } catch(ParseException e) { + } catch (ParseException e) { // Bad date so return null log.warn(value, e); } @@ -185,22 +394,25 @@ } /** - * <p>Checks if the field is a valid date. The pattern is used with - * <code>java.text.SimpleDateFormat</code>. If strict is true, then the - * length will be checked so '2/12/1999' will not pass validation with - * the format 'MM/dd/yyyy' because the month isn't two digits. - * The setLenient method is set to <code>false</code> for all.</p> - * - * @param value The value validation is being performed on. - * @param datePattern The pattern passed to <code>SimpleDateFormat</code>. - * @param strict Whether or not to have an exact match of the datePattern. + * <p> + * Checks if the field is a valid date. The pattern is used with <code>java.text.SimpleDateFormat</code> + * . If strict is true, then the length will be checked so '2/12/1999' will + * not pass validation with the format 'MM/dd/yyyy' because the month isn't + * two digits. The setLenient method is set to <code>false</code> for all. + * </p> + * + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] datePattern The pattern passed to <code>SimpleDateFormat</code>. + [EMAIL PROTECTED] strict Whether or not to have an exact match of the + * datePattern. + [EMAIL PROTECTED] */ public static Date formatDate(String value, String datePattern, boolean strict) { Date date = null; if (value == null - || datePattern == null - || datePattern.length() == 0) { + || datePattern == null + || datePattern.length() == 0) { return null; } @@ -215,7 +427,7 @@ date = null; } } - } catch(ParseException e) { + } catch (ParseException e) { // Bad date so return null log.warn(value, e); } @@ -224,14 +436,18 @@ } /** - * <p>Checks if the field is a valid credit card number.</p> - * <p>Reference Sean M. Burke's - * <a href="http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl">script</a>.</p> + * <p> + * Checks if the field is a valid credit card number.</p> <p> * - * @param value The value validation is being performed on. + * Reference Sean M. Burke's <a href="http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl"> + * script</a> .</p> + * + [EMAIL PROTECTED] value The value validation is being performed on. + [EMAIL PROTECTED] */ public static Long formatCreditCard(String value) { return GenericValidator.isCreditCard(value) ? new Long(value) : null; } } + Modified: jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/ValidatorAction.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/ValidatorAction.java?rev=164749&r1=164748&r2=164749&view=diff ============================================================================== --- jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/ValidatorAction.java (original) +++ jakarta/commons/proper/validator/trunk/src/share/org/apache/commons/validator/ValidatorAction.java Mon Apr 25 23:15:17 2005 @@ -581,7 +581,8 @@ this.validationClass.getMethod(this.method, this.parameterClasses); } catch (NoSuchMethodException e) { - throw new ValidatorException(e.getMessage()); + throw new ValidatorException("No such validation method: " + + e.getMessage()); } } @@ -750,4 +751,4 @@ return v.getOnlyReturnErrors(); } -} \ No newline at end of file +} Modified: jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/TestTypeValidator.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/TestTypeValidator.java?rev=164749&r1=164748&r2=164749&view=diff ============================================================================== --- jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/TestTypeValidator.java (original) +++ jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/TestTypeValidator.java Mon Apr 25 23:15:17 2005 @@ -21,6 +21,8 @@ package org.apache.commons.validator; +import java.util.Locale; + import org.apache.commons.validator.util.ValidatorUtils; /** @@ -43,6 +45,20 @@ } /** + * Checks if the field can be successfully converted to a <code>byte</code>. + * + * @param value The value validation is being performed on. + * @return boolean If the field can be successfully converted + * to a <code>byte</code> <code>true</code> is returned. + * Otherwise <code>false</code>. + */ + public static Byte validateByte(Object bean, Field field, Locale locale) { + String value = ValidatorUtils.getValueAsString(bean, field.getProperty()); + + return GenericTypeValidator.formatByte(value, locale); + } + + /** * Checks if the field can be successfully converted to a <code>short</code>. * * @param value The value validation is being performed on. @@ -57,6 +73,20 @@ } /** + * Checks if the field can be successfully converted to a <code>short</code>. + * + * @param value The value validation is being performed on. + * @return boolean If the field can be successfully converted + * to a <code>short</code> <code>true</code> is returned. + * Otherwise <code>false</code>. + */ + public static Short validateShort(Object bean, Field field, Locale locale) { + String value = ValidatorUtils.getValueAsString(bean, field.getProperty()); + + return GenericTypeValidator.formatShort(value, locale); + } + + /** * Checks if the field can be successfully converted to a <code>int</code>. * * @param value The value validation is being performed on. @@ -71,6 +101,20 @@ } /** + * Checks if the field can be successfully converted to a <code>int</code>. + * + * @param value The value validation is being performed on. + * @return boolean If the field can be successfully converted + * to a <code>int</code> <code>true</code> is returned. + * Otherwise <code>false</code>. + */ + public static Integer validateInt(Object bean, Field field, Locale locale) { + String value = ValidatorUtils.getValueAsString(bean, field.getProperty()); + + return GenericTypeValidator.formatInt(value, locale); + } + + /** * Checks if the field can be successfully converted to a <code>long</code>. * * @param value The value validation is being performed on. @@ -85,6 +129,20 @@ } /** + * Checks if the field can be successfully converted to a <code>long</code>. + * + * @param value The value validation is being performed on. + * @return boolean If the field can be successfully converted + * to a <code>long</code> <code>true</code> is returned. + * Otherwise <code>false</code>. + */ + public static Long validateLong(Object bean, Field field, Locale locale) { + String value = ValidatorUtils.getValueAsString(bean, field.getProperty()); + + return GenericTypeValidator.formatLong(value, locale); + } + + /** * Checks if the field can be successfully converted to a <code>float</code>. * * @param value The value validation is being performed on. @@ -99,6 +157,20 @@ } /** + * Checks if the field can be successfully converted to a <code>float</code>. + * + * @param value The value validation is being performed on. + * @return boolean If the field can be successfully converted + * to a <code>float</code> <code>true</code> is returned. + * Otherwise <code>false</code>. + */ + public static Float validateFloat(Object bean, Field field, Locale locale) { + String value = ValidatorUtils.getValueAsString(bean, field.getProperty()); + + return GenericTypeValidator.formatFloat(value, locale); + } + + /** * Checks if the field can be successfully converted to a <code>double</code>. * * @param value The value validation is being performed on. @@ -111,5 +183,18 @@ return GenericTypeValidator.formatDouble(value); } - + + /** + * Checks if the field can be successfully converted to a <code>double</code>. + * + * @param value The value validation is being performed on. + * @return boolean If the field can be successfully converted + * to a <code>double</code> <code>true</code> is returned. + * Otherwise <code>false</code>. + */ + public static Double validateDouble(Object bean, Field field, Locale locale) { + String value = ValidatorUtils.getValueAsString(bean, field.getProperty()); + + return GenericTypeValidator.formatDouble(value, locale); + } } Modified: jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/TypeTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/TypeTest.java?rev=164749&r1=164748&r2=164749&view=diff ============================================================================== --- jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/TypeTest.java (original) +++ jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/TypeTest.java Mon Apr 25 23:15:17 2005 @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.Iterator; +import java.util.Locale; import java.util.Map; import junit.framework.Test; @@ -133,6 +134,80 @@ //assertTrue(ACTION + " value ValidatorResult should contain the '" + ACTION +"' action.", result.containsAction(ACTION)); //assertTrue(ACTION + " value ValidatorResult for the '" + ACTION +"' action should have " + (passed ? "passed" : "failed") + ".", (passed ? result.isValid(ACTION) : !result.isValid(ACTION))); + } + + /** + * Tests the us locale + */ + public void testUSLocale() throws ValidatorException { + // Create bean to run test on. + TypeBean info = new TypeBean(); + info.setByte("12"); + info.setShort("129"); + info.setInteger("-144"); + info.setLong("88000"); + info.setFloat("12.1555"); + info.setDouble("129.1551511111"); + localeTest(info, Locale.US); + } + + /** + * Tests the fr locale. + */ + public void testFRLocale() throws ValidatorException { + // Create bean to run test on. + TypeBean info = new TypeBean(); + info.setByte("12"); + info.setShort("-129"); + info.setInteger("1443"); + info.setLong("88000"); + info.setFloat("12,1555"); + info.setDouble("129,1551511111"); + Map map = localeTest(info, Locale.FRENCH); + assertTrue("float value not correct", ((Float)map.get("float")).intValue() == 12); + assertTrue("double value not correct", ((Double)map.get("double")).intValue() == 129); + } + + /** + * Tests the locale. + */ + private Map localeTest(TypeBean info, Locale locale) throws ValidatorException { + + // Construct validator based on the loaded resources + // and the form key + Validator validator = new Validator(resources, "typeLocaleForm"); + // add the name bean to the validator as a resource + // for the validations to be performed on. + validator.setParameter(Validator.BEAN_PARAM, info); + validator.setParameter("java.util.Locale", locale); + + // Get results of the validation. + ValidatorResults results = null; + + // throws ValidatorException, + // but we aren't catching for testing + // since no validation methods we use + // throw this + results = validator.validate(); + + assertNotNull("Results are null.", results); + + Map hResultValues = results.getResultValueMap(); + + assertTrue("Expecting byte result to be an instance of Byte for locale: "+locale, (hResultValues.get("byte") instanceof Byte)); + assertTrue("Expecting short result to be an instance of Short for locale: "+locale, (hResultValues.get("short") instanceof Short)); + assertTrue("Expecting integer result to be an instance of Integer for locale: "+locale, (hResultValues.get("integer") instanceof Integer)); + assertTrue("Expecting long result to be an instance of Long for locale: "+locale, (hResultValues.get("long") instanceof Long)); + assertTrue("Expecting float result to be an instance of Float for locale: "+locale, (hResultValues.get("float") instanceof Float)); + assertTrue("Expecting double result to be an instance of Double for locale: "+locale, (hResultValues.get("double") instanceof Double)); + + for (Iterator i = hResultValues.keySet().iterator(); i.hasNext(); ) { + String key = (String)i.next(); + Object value = hResultValues.get(key); + + assertNotNull("value ValidatorResults.getResultValueMap() should not be null for locale: "+locale, value); + } + return hResultValues; } } Modified: jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-type.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-type.xml?rev=164749&r1=164748&r2=164749&view=diff ============================================================================== --- jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-type.xml (original) +++ jakarta/commons/proper/validator/trunk/src/test/org/apache/commons/validator/validator-type.xml Mon Apr 25 23:15:17 2005 @@ -10,23 +10,47 @@ methodParams="java.lang.Object,org.apache.commons.validator.Field" msg=""/> + <validator name="byteLocale" + classname="org.apache.commons.validator.TestTypeValidator" + method="validateByte" + methodParams="java.lang.Object,org.apache.commons.validator.Field,java.util.Locale" + msg=""/> + <validator name="short" classname="org.apache.commons.validator.TestTypeValidator" method="validateShort" methodParams="java.lang.Object,org.apache.commons.validator.Field" msg=""/> + <validator name="shortLocale" + classname="org.apache.commons.validator.TestTypeValidator" + method="validateShort" + methodParams="java.lang.Object,org.apache.commons.validator.Field,java.util.Locale" + msg=""/> + <validator name="int" classname="org.apache.commons.validator.TestTypeValidator" method="validateInt" methodParams="java.lang.Object,org.apache.commons.validator.Field" msg=""/> + <validator name="intLocale" + classname="org.apache.commons.validator.TestTypeValidator" + method="validateInt" + methodParams="java.lang.Object,org.apache.commons.validator.Field,java.util.Locale" + msg=""/> + <validator name="long" classname="org.apache.commons.validator.TestTypeValidator" method="validateLong" methodParams="java.lang.Object,org.apache.commons.validator.Field" msg=""/> + + <validator name="longLocale" + classname="org.apache.commons.validator.TestTypeValidator" + method="validateLong" + methodParams="java.lang.Object,org.apache.commons.validator.Field,java.util.Locale " + msg=""/> <validator name="float" classname="org.apache.commons.validator.TestTypeValidator" @@ -34,12 +58,24 @@ methodParams="java.lang.Object,org.apache.commons.validator.Field" msg=""/> + <validator name="floatLocale" + classname="org.apache.commons.validator.TestTypeValidator" + method="validateFloat" + methodParams="java.lang.Object,org.apache.commons.validator.Field,java.util.Locale" + msg=""/> + <validator name="double" classname="org.apache.commons.validator.TestTypeValidator" method="validateDouble" methodParams="java.lang.Object,org.apache.commons.validator.Field" msg=""/> + <validator name="doubleLocale" + classname="org.apache.commons.validator.TestTypeValidator" + method="validateDouble" + methodParams="java.lang.Object,org.apache.commons.validator.Field,java.util.Locale" + msg=""/> + </global> <formset> <form name="typeForm"> @@ -49,6 +85,14 @@ <field property="long" depends="long"/> <field property="float" depends="float"/> <field property="double" depends="double"/> + </form> + <form name="typeLocaleForm"> + <field property="byte" depends="byteLocale"/> + <field property="short" depends="shortLocale"/> + <field property="integer" depends="intLocale"/> + <field property="long" depends="longLocale"/> + <field property="float" depends="floatLocale"/> + <field property="double" depends="doubleLocale"/> </form> </formset> </form-validation> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]