Return-Path: X-Original-To: apmail-incubator-flex-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-flex-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B77DA965A for ; Mon, 5 Mar 2012 06:04:19 +0000 (UTC) Received: (qmail 26730 invoked by uid 500); 5 Mar 2012 06:04:19 -0000 Delivered-To: apmail-incubator-flex-commits-archive@incubator.apache.org Received: (qmail 26701 invoked by uid 500); 5 Mar 2012 06:04:19 -0000 Mailing-List: contact flex-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: flex-dev@incubator.apache.org Delivered-To: mailing list flex-commits@incubator.apache.org Received: (qmail 26683 invoked by uid 99); 5 Mar 2012 06:04:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2012 06:04:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2012 06:04:17 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B227D2388865; Mon, 5 Mar 2012 06:03:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1296940 - /incubator/flex/whiteboard/jmclean/validators/src/mx/validators/PostCodeValidator.as Date: Mon, 05 Mar 2012 06:03:57 -0000 To: flex-commits@incubator.apache.org From: jmclean@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120305060357.B227D2388865@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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); } }