Browse Source

Added Portugal postcode validation

José Mira 11 years ago
parent
commit
a6029e7b23
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/js/validator/zipCode.js

+ 7 - 1
src/js/validator/zipCode.js

@@ -14,6 +14,7 @@
             IT: 'Italy',
             MA: 'Morocco',
             NL: 'Netherlands',
+            PT: 'Portugal',
             RO: 'Romania',
             RU: 'Russia',
             SE: 'Sweden',
@@ -29,7 +30,7 @@
             country: 'country'
         },
 
-        COUNTRY_CODES: ['BR', 'CA', 'CZ', 'DK', 'FR', 'GB', 'IE', 'IT', 'MA', 'NL', 'RO', 'RU', 'SE', 'SG', 'SK', 'US'],
+        COUNTRY_CODES: ['BR', 'CA', 'CZ', 'DK', 'FR', 'GB', 'IE', 'IT', 'MA', 'NL', 'PT', 'RO', 'RU', 'SE', 'SG', 'SK', 'US'],
 
         /**
          * Return true if and only if the input value is a valid country zip code
@@ -119,6 +120,11 @@
                 case 'NL':
                     isValid = /^[1-9][0-9]{3} ?(?!sa|sd|ss)[a-z]{2}$/i.test(value);
                     break;
+                
+                // Test: http://refiddle.com/1l2t
+                case 'PT':
+                    isValid = /^[1-9]\d{3}-\d{3}$/.test(value);
+                    break;
                     
                 case 'RO':
                     isValid = /^(0[1-8]{1}|[1-9]{1}[0-5]{1})?[0-9]{4}$/i.test(value);