flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcl...@apache.org
Subject svn commit: r1296718 - in /incubator/flex/whiteboard/jmclean/validators/src: mx/validators/PostCodeValidator.as tests/PostCodeValidatorTests.as
Date Sat, 03 Mar 2012 22:36:01 GMT
Author: jmclean
Date: Sat Mar  3 22:36:01 2012
New Revision: 1296718

URL: http://svn.apache.org/viewvc?rev=1296718&view=rev
Log:
made invalid length errors less important that invalid character or invalid format errors

Modified:
    incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as
    incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as

Modified: incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as?rev=1296718&r1=1296717&r2=1296718&view=diff
==============================================================================
--- incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as (original)
+++ incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as Sat
Mar  3 22:36:01 2012
@@ -144,12 +144,14 @@ public class PostCodeValidator extends V
 				return [];
 			}
 			
-			errors.push({invalidFormat:invalidFormat, invalidChar:invalidChar,
-				wrongLength:wrongLength, count:invalidFormat + invalidChar + wrongLength})
+			// We want invalid char and invalid format errors show in preference
+			// so give wong length errors a higher value
+			errors.push({invalidFormat:invalidFormat, invalidChar:invalidChar, wrongLength:wrongLength,
+				count:Number(invalidFormat) + Number(invalidChar) + Number(wrongLength)*1.5})
 		}
 		
 		// return result with least number of errors
-		// TODO return/remember closest format?
+		// TODO return/remember closest format or place in error string?
 		errors.sortOn("count", Array.NUMERIC);
 		
 		if (errors[0].invalidChar)

Modified: incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as?rev=1296718&r1=1296717&r2=1296718&view=diff
==============================================================================
--- incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as (original)
+++ incubator/flex/whiteboard/jmclean/validators/src/tests/PostCodeValidatorTests.as Sat Mar
 3 22:36:01 2012
@@ -138,9 +138,7 @@ package tests
 			
 			results = PostCodeValidator.validatePostCode(validator, "1234^6", null);
 			assertTrue("Invalid Postcode", results.length == 1);
-			// This could be a wrong length or invalid char error
-			//TODO change so that invalid char or format error is more important than a wrong length
error.
-			wrongLengthError(results);
+			invalidCharError(results);
 			
 			results = PostCodeValidator.validatePostCode(validator, "1-23", null);
 			assertTrue("Invalid Postcode", results.length == 1);



Mime
View raw message