incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcl...@apache.org
Subject svn commit: r1296940 - /incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as
Date Mon, 05 Mar 2012 06:03:57 GMT
Author: jmclean
Date: Mon Mar  5 06:03:57 2012
New Revision: 1296940

URL: http://svn.apache.org/viewvc?rev=1296940&view=rev
Log:
removed static variables as the instance is passed into doValidate

Modified:
    incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.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=1296940&r1=1296939&r2=1296940&view=diff
==============================================================================
--- incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as (original)
+++ incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as Mon
Mar  5 06:03:57 2012
@@ -73,19 +73,14 @@ public class PostCodeValidator extends V
 	 *  @productversion ApacheFlex 4.8
      */
     public static function validatePostCode(validator:PostCodeValidator,
-                                           value:Object,
+                                           postCode:String,
                                            baseField:String):Array
     {
         var results:Array = [];
-    
-        // Resource-backed properties of the validator.
-        var resourceManager:IResourceManager = ResourceManager.getInstance();
 
-        var postCode:String = String(value);
         var length:int = postCode.length;
 		var formatLength:int;
-		var noformats:int = _formats.length;
-		var validLetters:String = "CAN";
+		var noformats:int = validator.formats.length;
 		var spacers:String = " -";
 		
 		var errors:Array = [];
@@ -100,13 +95,14 @@ public class PostCodeValidator extends V
 			countryDigit = 0;
 			invalidChar = false;
 			invalidFormat = false;
-			formatLength = _formats[f].length;
+			formatLength = validator.formats[f].length;
 			
 			for (var i:int = 0; i < length; i++)
 			{
 				var char:String = postCode.charAt(i);
-				var formatChar:String = _formats[f].charAt(i);
+				var formatChar:String = validator.formats[f].charAt(i);
 				
+				// ignore character past end of format string
 				if (i >= formatLength) {
 					break;
 				}
@@ -126,7 +122,7 @@ public class PostCodeValidator extends V
 				}
 				else if (formatChar == "C")
 				{
-					if (countryDigit >= 2 || !_countryCode || char != _countryCode.charAt(countryDigit))
+					if (countryDigit >= 2 || !validator.countryCode || char != validator.countryCode.charAt(countryDigit))
 					{
 						invalidFormat = true;
 					}
@@ -145,7 +141,7 @@ public class PostCodeValidator extends V
 			}
 			
 			// We want invalid char and invalid format errors show in preference
-			// so give wong length errors a higher value
+			// so give wrong length errors a higher value
 			errors.push({invalidFormat:invalidFormat, invalidChar:invalidChar, wrongLength:wrongLength,
 				count:Number(invalidFormat) + Number(invalidChar) + Number(wrongLength)*1.5})
 		}
@@ -206,13 +202,13 @@ public class PostCodeValidator extends V
 	 *  @private
 	 *  The two letter country code used in some postcode formats
 	 */
-	protected static var _countryCode:String;
+	private var _countryCode:String;
 	
 	/**
 	 *  @private
 	 *  An array of the postcode formats to check against.
 	 */
-	protected static var _formats:Array = [];
+	private var _formats:Array = [];
 	
 	/** 
 	 *  Format of postcode
@@ -488,7 +484,7 @@ public class PostCodeValidator extends V
         if (results.length > 0 || ((val.length == 0) && !required))
             return results;
         else
-            return PostCodeValidator.validatePostCode(this, value, null);
+            return PostCodeValidator.validatePostCode(this, String(value), null);
     }
 }
 



Mime
View raw message