浏览代码

#65: Support Sweden zip code

nghuuphuoc 11 年之前
父节点
当前提交
79f24029d6
共有 5 个文件被更改,包括 9 次插入1 次删除
  1. 1 0
      CHANGELOG.md
  2. 1 0
      README.md
  3. 3 0
      dist/js/bootstrapValidator.js
  4. 1 1
      dist/js/bootstrapValidator.min.js
  5. 3 0
      src/js/validator/zipCode.js

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@ __New features__:
 
 * [#44: Rewrite entirely using Deferred](https://github.com/nghuuphuoc/bootstrapvalidator/issues/44)
 * [#64: Support Danish zip code](https://github.com/nghuuphuoc/bootstrapvalidator/issues/64)
+* [#65: Support Sweden zip code](https://github.com/nghuuphuoc/bootstrapvalidator/issues/64)
 * [#71: Show all errors](https://github.com/nghuuphuoc/bootstrapvalidator/issues/71)
 
 __Fixes__:

+ 1 - 0
README.md

@@ -229,6 +229,7 @@ max         | n/a     | The maximum length. One of ```min```, ```max``` options
 | country     | US      | A ISO 3166 country code. Currently it supports the following countries:
 |             |         | - US (United State)
 |             |         | - DK (Denmark)
+|             |         | - SE (Sweden)
 
 ## Write new validator
 

+ 3 - 0
dist/js/bootstrapValidator.js

@@ -838,6 +838,7 @@
          * Currently it supports the following countries:
          * - US (United State)
          * - DK (Denmark)
+         * - SE (Sweden)
          *
          * @returns {Boolean}
          */
@@ -849,6 +850,8 @@
             switch (options.country.toUpperCase()) {
                 case 'DK':
                     return /^(DK(-|\s)?)?\d{4}$/i.test(value);
+                case 'SE':
+                    return /^(S-)?\d{3}\s?\d{2}$/i.test(value);
                 case 'US':
                 default:
                     return /^\d{5}([\-]\d{4})?$/.test(value);

文件差异内容过多而无法显示
+ 1 - 1
dist/js/bootstrapValidator.min.js


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

@@ -11,6 +11,7 @@
          * Currently it supports the following countries:
          * - US (United State)
          * - DK (Denmark)
+         * - SE (Sweden)
          *
          * @returns {Boolean}
          */
@@ -22,6 +23,8 @@
             switch (options.country.toUpperCase()) {
                 case 'DK':
                     return /^(DK(-|\s)?)?\d{4}$/i.test(value);
+                case 'SE':
+                    return /^(S-)?\d{3}\s?\d{2}$/i.test(value);
                 case 'US':
                 default:
                     return /^\d{5}([\-]\d{4})?$/.test(value);