  */
 public class ZipCodeValidator extends Validator
 {
-	include "../core/Version.as";
-
-	//--------------------------------------------------------------------------
-	//
-	//  Class constants
-	//
-	//--------------------------------------------------------------------------
-
-    /**
-	 *  @private
-	 */
-	private static const DOMAIN_US:uint = 1;
-    
-    /**
-	 *  @private
-	 */
-	private static const DOMAIN_US_OR_CANADA:uint = 2;
-
-	//--------------------------------------------------------------------------
-	//
-	//  Class methods
-	//
-	//--------------------------------------------------------------------------
-
-	/**
-	 *  Convenience method for calling a validator.
-	 *  Each of the standard Flex validators has a similar convenience method.
-	 *
-	 *  @param validator The ZipCodeValidator instance.
-	 *
-	 *  @param value A field to validate.
-	 *
-	 *  @param baseField Text representation of the subfield
-	 *  specified in the <code>value</code> parameter.
-	 *  For example, if the <code>value</code> parameter specifies value.zipCode,
-	 *  the <code>baseField</code> value is <code>"zipCode"</code>.
-     *
-	 *  @return An Array of ValidationResult objects, with one ValidationResult 
-	 *  object for each field examined by the validator. 
-	 *
-	 *  @see mx.validators.ValidationResult
-	 *
-	 */
+    include "../core/Version.as";
+
+    //--------------------------------------------------------------------------
+    //
+    //  Class constants
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    private static const DOMAIN_US:uint = 1;
+    
+    /**
+     *  @private
+     */
+    private static const DOMAIN_US_OR_CANADA:uint = 2;
+    
+    /**
+     * @private 
+     */
+     private static const DOMAIN_CANADA:uint = 3;   
+
+    //--------------------------------------------------------------------------
+    //
+    //  Class methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Convenience method for calling a validator.
+     *  Each of the standard Flex validators has a similar convenience method.
+     *
+     *  @param validator The ZipCodeValidator instance.
+     *
+     *  @param value A field to validate.
+     *
+     *  @param baseField Text representation of the subfield
+     *  specified in the <code>value</code> parameter.
+     *  For example, if the <code>value</code> parameter specifies value.zipCode,
+     *  the <code>baseField</code> value is <code>"zipCode"</code>.
+     *
+     *  @return An Array of ValidationResult objects, with one ValidationResult 
+     *  object for each field examined by the validator. 
+     *
+     *  @see mx.validators.ValidationResult
+     *
+     */
     public static function validateZipCode(validator:ZipCodeValidator,
-										   value:Object,
-										   baseField:String):Array
-    {
-		var results:Array = [];
-	
-		// Resource-backed properties of the validator.
-		var allowedFormatChars:String = validator.allowedFormatChars;
-		var domain:String = validator.domain;
-
-		var resourceManager:IResourceManager = ResourceManager.getInstance();
+                                           value:Object,
+                                           baseField:String):Array
+    {
+        var results:Array = [];
+    
+        // Resource-backed properties of the validator.
+        var allowedFormatChars:String = validator.allowedFormatChars;
+        var domain:String = validator.domain;
+
+        var resourceManager:IResourceManager = ResourceManager.getInstance();
 
         var zip:String = String(value);
         var len:int = zip.length;
         
-		var domainType:uint = DOMAIN_US;
-        if (domain == ZipCodeValidatorDomainType.US_OR_CANADA)
-		{
-            domainType = DOMAIN_US_OR_CANADA;
-        }
-        else if (domain == ZipCodeValidatorDomainType.US_ONLY)
-		{
-            domainType = DOMAIN_US;
-        }
-        else
-        {
-			results.push(new ValidationResult(
-				true, baseField, "invalidDomain",
-				validator.invalidDomainError));
-            return results;
-        }
-
-		var n:int;
-		var i:int;
-		var c:String;
-		
+        var domainType:uint = DOMAIN_US;
+        switch (domain)
+        {
+            case ZipCodeValidatorDomainType.US_OR_CANADA:
+            {
+                domainType = DOMAIN_US_OR_CANADA;
+                break;
+            }
+            
+            case ZipCodeValidatorDomainType.US_ONLY:
+            {
+                domainType = DOMAIN_US;
+                break;
+            }
+            
+            case ZipCodeValidatorDomainType.CANADA_ONLY:
+            {
+                domainType = DOMAIN_CANADA;
+                break;
+            }
+            
+            default:
+            {
+                results.push(new ValidationResult(
+                    true, baseField, "invalidDomain",
+                    validator.invalidDomainError));
+                return results;
+            }
+            
+        }
+        
+        var n:int;
+        var i:int;
+        var c:String;
+        
         // Make sure localAllowedFormatChars contains no numbers or letters.
         n = allowedFormatChars.length;
-		for (i = 0; i < n; i++)
+        for (i = 0; i < n; i++)
         {
             c = allowedFormatChars.charAt(i);
             if (DECIMAL_DIGITS.indexOf(c) != -1 ||
                 ROMAN_LETTERS.indexOf(c) != -1)
             {
-				var message:String = resourceManager.getString(
-					"validators", "invalidFormatCharsZCV");
-				throw new Error(message);
+                var message:String = resourceManager.getString(
+                    "validators", "invalidFormatCharsZCV");
+                throw new Error(message);
             }
         }
 
         // Now start checking the ZIP code.
         // At present, only US and Canadian ZIP codes are supported.
-		// As a result, the easiest thing to check first
-		// to determine the domain is the length.
-		// A length of 5 or 10 means a US ZIP code
-		// and a length of 6 or 7 means a Canadian ZIP.
+        // As a result, the easiest thing to check first
+        // to determine the domain is the length.
+        // A length of 5 or 10 means a US ZIP code
+        // and a length of 6 or 7 means a Canadian ZIP.
         // If more countries are supported in the future, it may make sense
-		// to check other conditions first depending on the domain specified
-		// and all the possible ZIP code formats for that domain.
-		// For now, this approach makes the most sense.
-
-        // Find out if the ZIP code contains any letters.
-        var containsLetters:Boolean = false;
-        for (i = 0; i < len; i++)
-        {
-            if (ROMAN_LETTERS.indexOf(zip.charAt(i)) != -1)
-            {
-                containsLetters = true;
-                break;
-            }
-        }
+        // to check other conditions first depending on the domain specified
+        // and all the possible ZIP code formats for that domain.
+        // For now, this approach makes the most sense.
 
         // Make sure there are no invalid characters in the ZIP.
         for (i = 0; i < len; i++)

package mx.validators
{

import mx.managers.ISystemManager;
import mx.managers.SystemManager;
import mx.resources.IResourceManager;
import mx.resources.ResourceManager;


 *  <pre>
 *  &lt;mx:ZipCodeValidator
 *    allowedFormatChars=" -" 
 *    domain="US Only | US or Canada | Canada Only"
 *    invalidCharError="The ZIP code contains invalid characters." 
 *    invalidDomainError="The domain parameter is invalid. It must be either 'US Only', 'Canada Only', or 'US or Canada'." 
 *    wrongCAFormatError="The Canadian postal code must be formatted 'A1B 2C3'." 
 *    wrongLengthError="The ZIP code must be 5 digits or 5+4 digits." 
 *    wrongUSFormatError="The ZIP+4 code must be formatted '12345-6789'." 
