Skip to content

Commit

Permalink
#198: Add Canada support for zipCode validator
Browse files Browse the repository at this point in the history
  • Loading branch information
nghuuphuoc committed Apr 21, 2014
1 parent 62caca6 commit 55cba32
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion bootstrapValidator.jquery.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrapValidator",
"version": "0.4.2",
"version": "0.4.3-dev",
"title": "BootstrapValidator",
"author": {
"name": "Nguyen Huu Phuoc",
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion dist/css/bootstrapValidator.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions dist/js/bootstrapValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2357,6 +2357,7 @@
*
* Currently it supports the following countries:
* - US (United State)
* - CA (Canada)
* - DK (Denmark)
* - SE (Sweden)
* @returns {Boolean}
Expand All @@ -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':
Expand Down
4 changes: 2 additions & 2 deletions dist/js/bootstrapValidator.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
5 changes: 3 additions & 2 deletions src/js/validator/zipCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
* Currently it supports the following countries:
* - US (United State)
* - CA (Canada)
* - DK (Denmark)
* - SE (Sweden)
* @returns {Boolean}
Expand All @@ -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':
Expand Down

0 comments on commit 55cba32

Please sign in to comment.