← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21495: Validation / math utils. Set a max length for numeric values which are within postgres datatype a...

 

------------------------------------------------------------
revno: 21495
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-12-18 12:39:40 +0100
message:
  Validation / math utils. Set a max length for numeric values which are within postgres datatype and java double max size.
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java	2015-10-19 10:28:05 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java	2015-12-18 11:39:40 +0000
@@ -67,6 +67,7 @@
     private static IntegerValidator INT_VALIDATOR = new IntegerValidator();
     
     private static final double TOLERANCE = 0.01;
+    private static final int NUMBER_MAX_LENGTH = 250;
     
     public static final String NUMERIC_REGEXP = "^(-?0|-?[1-9]\\d*)(\\.\\d+)?$";
     public static final String NUMERIC_LENIENT_REGEXP = "^(-?[0-9]+)(\\.[0-9]+)?$";
@@ -355,7 +356,8 @@
      */
     public static boolean isNumeric( String value )
     {
-        return value != null && DOUBLE_VALIDATOR.isValid( value, LOCALE ) && NUMERIC_PATTERN.matcher( value ).matches();
+        return value != null && DOUBLE_VALIDATOR.isValid( value, LOCALE ) && 
+            NUMERIC_PATTERN.matcher( value ).matches() && value.length() < NUMBER_MAX_LENGTH;
     }
 
     /**