Browse Source

#198: Add Canada support for zipCode validator

phuoc 11 years ago
parent
commit
55cba329cb

+ 4 - 0
CHANGELOG.md

@@ -1,5 +1,9 @@
 # Change Log
 
+## v0.4.3 (not released yet)
+
+* [#198](https://github.com/nghuuphuoc/bootstrapvalidator/pull/198): Add Canadian Postal Code support for the [```zipCode``` validator](http://bootstrapvalidator.com/validators/zip-code/), thanks to [@Francismori7](https://github.com/Francismori7)
+
 ## v0.4.2 (2014-04-19)
 
 * [#168](https://github.com/nghuuphuoc/bootstrapvalidator/pull/168): Add siren and siret validators, thanks to [@jswale](https://github.com/jswale)

+ 1 - 0
README.md

@@ -86,6 +86,7 @@ Big thanks to the contributors:
 * [@adgrafik](https://github.com/adgrafik)
 * [@easonhan007](https://github.com/easonhan007)
 * [@emilchristensen](https://github.com/emilchristensen)
+* [@Francismori7](https://github.com/Francismori7)
 * [@gercheq](https://github.com/gercheq)
 * [@khangvm53](https://github.com/khangvm53)
 * [@kristian-puccio](https://github.com/kristian-puccio)

+ 1 - 1
bootstrapValidator.jquery.json

@@ -1,6 +1,6 @@
 {
     "name": "bootstrapValidator",
-    "version": "0.4.2",
+    "version": "0.4.3-dev",
     "title": "BootstrapValidator",
     "author": {
         "name": "Nguyen Huu Phuoc",

+ 1 - 1
bower.json

@@ -1,7 +1,7 @@
 {
     "name": "bootstrapValidator",
     "description": "The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3",
-    "version": "0.4.2",
+    "version": "0.4.3-dev",
     "main": [
         "dist/css/bootstrapValidator.css",
         "dist/js/bootstrapValidator.js"

+ 1 - 1
dist/css/bootstrapValidator.min.css

@@ -3,7 +3,7 @@
  *
  * A jQuery plugin to validate form fields. Use with Bootstrap 3
  *
- * @version     v0.4.2
+ * @version     v0.4.3-dev
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 6 - 3
dist/js/bootstrapValidator.js

@@ -3,7 +3,7 @@
  *
  * A jQuery plugin to validate form fields. Use with Bootstrap 3
  *
- * @version     v0.4.2
+ * @version     v0.4.3-dev
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -2357,6 +2357,7 @@
          *
          * Currently it supports the following countries:
          * - US (United State)
+         * - CA (Canada)
          * - DK (Denmark)
          * - SE (Sweden)
          * @returns {Boolean}
@@ -2367,8 +2368,10 @@
                 return true;
             }
 
-            options.country = options.country || 'US';
-            switch (options.country.toUpperCase()) {
+            var country = (options.country || 'US').toUpperCase();
+            switch (country) {
+                case 'CA':
+                    return /(?:A|B|C|E|G|J|K|L|M|N|P|R|S|T|V|X|Y){1}[0-9]{1}(?:A|B|C|E|G|J|K|L|M|N|P|R|S|T|V|X|Y){1}\s?[0-9]{1}(?:A|B|C|E|G|J|K|L|M|N|P|R|S|T|V|X|Y){1}[0-9]{1}/i.test(value);
                 case 'DK':
                     return /^(DK(-|\s)?)?\d{4}$/i.test(value);
                 case 'SE':

File diff suppressed because it is too large
+ 2 - 2
dist/js/bootstrapValidator.min.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
     "name": "bootstrapValidator",
-    "version": "0.4.2",
+    "version": "0.4.3-dev",
     "description": "The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3",
     "keywords": ["jQuery", "plugin", "validate", "validator", "form", "Bootstrap"],
     "author": {

+ 3 - 2
src/js/validator/zipCode.js

@@ -16,6 +16,7 @@
          *
          * Currently it supports the following countries:
          * - US (United State)
+         * - CA (Canada)
          * - DK (Denmark)
          * - SE (Sweden)
          * @returns {Boolean}
@@ -26,8 +27,8 @@
                 return true;
             }
 
-            options.country = options.country || 'US';
-            switch (options.country.toUpperCase()) {
+            var country = (options.country || 'US').toUpperCase();
+            switch (country) {
                 case 'CA':
                     return /(?:A|B|C|E|G|J|K|L|M|N|P|R|S|T|V|X|Y){1}[0-9]{1}(?:A|B|C|E|G|J|K|L|M|N|P|R|S|T|V|X|Y){1}\s?[0-9]{1}(?:A|B|C|E|G|J|K|L|M|N|P|R|S|T|V|X|Y){1}[0-9]{1}/i.test(value);
                 case 'DK':