ソースを参照

#638: Add Brazilian post code validator, thanks to @fhferreira

Phuoc Nguyen 11 年 前
コミット
106b40b7e9

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ __New features__
 * [#267](https://github.com/nghuuphuoc/bootstrapvalidator/issues/267), [#532](https://github.com/nghuuphuoc/bootstrapvalidator/pull/532): Add imo validator, thanks to [@troymccabe](https://github.com/troymccabe)
 * The [phone](http://bootstrapvalidator.com/validators/phone/) validator now supports Brazil ([#638](https://github.com/nghuuphuoc/bootstrapvalidator/pull/638)), French ([#510](https://github.com/nghuuphuoc/bootstrapvalidator/pull/510)), Spanish ([#536](https://github.com/nghuuphuoc/bootstrapvalidator/pull/536)) phone number, thanks to [@fhferreira](https://github.com/fhferreira), [@dlucazeau](https://github.com/dlucazeau) and [@vadail](https://github.com/vadail)
 * [#519](https://github.com/nghuuphuoc/bootstrapvalidator/pull/519), [#637](https://github.com/nghuuphuoc/bootstrapvalidator/pull/637): Add validator for Iceland and South African [VAT](http://bootstrapvalidator.com/validators/vat/) numbers, thanks to [@evilchili](https://github.com/evilchili)
+* [#638](https://github.com/nghuuphuoc/bootstrapvalidator/pull/638): Add Brazilian [post code](http://bootstrapvalidator.com/validators/zipCode/) validator, thanks to [@fhferreira](https://github.com/fhferreira)
 
 __Improvements__
 

+ 1 - 1
Gruntfile.js

@@ -115,7 +115,7 @@ module.exports = function(grunt) {
     });
 
     grunt.registerTask('default', 'build');
-    grunt.registerTask('build',   ['copy', 'cssmin', 'concat:source', 'uglify']);
+    grunt.registerTask('build',   ['copy', 'cssmin', 'concat', 'uglify']);
 
     grunt.loadNpmTasks('grunt-contrib-concat');
     grunt.loadNpmTasks('grunt-contrib-copy');

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

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.1-dev, built on 2014-08-08 7:01:35 PM
+ * @version     v0.5.1-dev, built on 2014-08-09 8:04:27 AM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 8 - 18
dist/js/bootstrapValidator.js

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.1-dev, built on 2014-08-08 7:01:35 PM
+ * @version     v0.5.1-dev, built on 2014-08-09 8:04:27 AM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -6513,6 +6513,7 @@
         countryNotSupported: 'The country code %s is not supported',
         country: 'Please enter a valid %s',
         countries: {
+            BR: 'Brazilian postal code',
             CA: 'Canadian postal code',
             DK: 'Danish postal code',
             GB: 'United Kingdom postal code',
@@ -6520,8 +6521,7 @@
             NL: 'Dutch postal code',
             SE: 'Swiss postal code',
             SG: 'Singapore postal code',
-            US: 'US zip code',
-            BR: 'Brazilian postal code'
+            US: 'US zip code'
         }
     });
 
@@ -6531,7 +6531,7 @@
             country: 'country'
         },
 
-        COUNTRY_CODES: ['CA', 'DK', 'GB', 'IT', 'NL', 'SE', 'SG', 'US', 'BR'],
+        COUNTRY_CODES: ['BR', 'CA', 'DK', 'GB', 'IT', 'NL', 'SE', 'SG', 'US'],
 
         /**
          * Return true if and only if the input value is a valid country zip code
@@ -6544,16 +6544,6 @@
          *
          * The country can be defined by:
          * - An ISO 3166 country code
-         * Currently it supports the following countries:
-         *      - US (United States)
-         *      - CA (Canada)
-         *      - DK (Denmark)
-         *      - GB (United Kingdom)
-         *      - IT (Italy)
-         *      - NL (Netherlands)
-         *      - SE (Sweden)
-         *      - SG (Singapore)
-         *
          * - Name of field which its value defines the country code
          * - Name of callback function that returns the country code
          * - A callback function that returns the country code
@@ -6585,6 +6575,10 @@
             var isValid = false;
             country = country.toUpperCase();
             switch (country) {
+                case 'BR':
+                    isValid = /^(\d{2})([\.]?)(\d{3})([\-]?)(\d{3})$/.test(value);
+                    break;
+
                 case 'CA':
                     isValid = /^(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|X|Y){1}[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}\s?[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}[0-9]{1}$/i.test(value);
                     break;
@@ -6615,10 +6609,6 @@
                     isValid = /^([0][1-9]|[1-6][0-9]|[7]([0-3]|[5-9])|[8][0-2])(\d{4})$/i.test(value);
                     break;
                     
-                case 'BR':
-                    isValid = /^(\d{2})([\.]?)(\d{3})([\-]?)(\d{3})$/.test(value);
-                    break;
-
                 case 'US':
                 /* falls through */
                 default:

ファイルの差分が大きいため隠しています
+ 2 - 2
dist/js/bootstrapValidator.min.js


+ 1 - 0
dist/js/language/be_NL.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'De land code %s is niet ondersteund',
             country: 'Please enter a valid %s',
             countries: {
+                BR: 'Braziliaans postcode',
                 CA: 'Canadeese postcode',
                 DK: 'Deense postcode',
                 GB: 'Engelse postcode',

+ 1 - 0
dist/js/language/bg_BG.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Кода на държавата %s не се поддържа',
             country: 'Моля, въведете валиден %s',
             countries: {
+                BR: 'Бразилска пощенски код',
                 CA: 'Канадски пощенски код',
                 DK: 'Датски пощенски код',
                 GB: 'Пощенски код Великобритания',

+ 1 - 0
dist/js/language/cs_CZ.js

@@ -323,6 +323,7 @@
             countryNotSupported: '%s není podporované',
             country: 'Prosím zadejte správné %s',
             countries: {
+                BR: 'Brazílii PSČ',
                 CA: 'Kanadské PSČ',
                 DK: 'Dánské PSČ',
                 GB: 'PSČ Velké Británie',

+ 1 - 0
dist/js/language/da_DK.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Landekoden %s understøttes desværre ikke',
             country: 'Udfyld venligst dette felt med et gyldigt %s',
             countries: {
+                BR: 'brasiliansk postnummer',
                 CA: 'canadisk postnummer',
                 DK: 'dansk postnummer',
                 GB: 'engelsk postnummer',

+ 1 - 0
dist/js/language/de_DE.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Der Ländercode %s wird nicht unterstützt',
             country: 'Bitte gültigen Code %s eingeben',
             countries: {
+                BR: 'Brasilianisch Postleitzahl',
                 CA: 'Kanadische Postleitzahl',
                 DK: 'Dänische Postleitzahl',
                 GB: 'Englische Postleitzahl',

+ 1 - 0
dist/js/language/en_US.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'The country code %s is not supported',
             country: 'Please enter a valid %s',
             countries: {
+                BR: 'Brazilian postal code',
                 CA: 'Canadian postal code',
                 DK: 'Danish postal code',
                 GB: 'United Kingdom postal code',

+ 1 - 0
dist/js/language/es_CL.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'El código del país %s no está soportado',
             country: 'Por favor ingrese un %s válido',
             countries: {
+                BR: 'código postal Brasileño',
                 CA: 'código postal Canadiense',
                 DK: 'código postal Danés',
                 GB: 'código postal Británico',

+ 1 - 0
dist/js/language/es_ES.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'El código del país %s no está soportado',
             country: 'Por favor introduce un %s válido',
             countries: {
+                BR: 'código postal Brasileño',
                 CA: 'código postal Canadiense',
                 DK: 'código postal Danés',
                 GB: 'código postal Británico',

+ 1 - 0
dist/js/language/fr_FR.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Le code de pays %s n\'est pas accepté',
             country: 'Veuillez fournir un %s valide',
             countries: {
+                BR: 'code postal brésilien',
                 CA: 'code postal canadien',
                 DK: 'code postal dannois',
                 GB: 'code postal anglais',

+ 1 - 0
dist/js/language/gr_EL.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Ο κωδικός χώρας %s δεν υποστηρίζεται',
             country: 'Παρακαλώ εισάγετε ένα έγκυρο %s',
             countries: {
+                BR: 'ταχυδρομικό κώδικα Βραζιλίας',
                 CA: 'ταχυδρομικό κώδικα Καναδά',
                 DK: 'ταχυδρομικό κώδικα Δανίας',
                 GB: 'ταχυδρομικό κώδικα Ηνωμένου Βασιλείου',

+ 1 - 0
dist/js/language/hu_HU.js

@@ -323,6 +323,7 @@
             countryNotSupported: '%s - nem támogatott ország',
             country: 'Kérlek, hogy helyes %s irányítószámot adj meg',
             countries: {
+                BR: 'brazil',
                 CA: 'kanadai',
                 DK: 'dán',
                 GB: 'Egyesült Királyság beli',

+ 9 - 8
dist/js/language/it_IT.js

@@ -323,14 +323,15 @@
             countryNotSupported: 'Il codice nazione %s non e supportato',
             country: 'Si prega di inserire un valido  %s',
             countries: {
-                'CA': 'Codice postale Canadese',
-                'DK': 'Codice postale Danese',
-                'GB': 'Codice postale del Regno Unito',
-                'IT': 'Codice postale Italiano',
-                'NL': 'Codice postale Olandese',
-                'SE': 'Codice postale Svizzero',
-                'SG': 'Codice postale di Singapore',
-                'US': 'Codice postale US'
+                BR: 'Codice postale Brasiliano',
+                CA: 'Codice postale Canadese',
+                DK: 'Codice postale Danese',
+                GB: 'Codice postale del Regno Unito',
+                IT: 'Codice postale Italiano',
+                NL: 'Codice postale Olandese',
+                SE: 'Codice postale Svizzero',
+                SG: 'Codice postale di Singapore',
+                US: 'Codice postale US'
             }
         }
     });

+ 1 - 0
dist/js/language/pl_PL.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Kod kraju %s nie jest obsługiwany',
             country: 'Wprowadź poprawny %s kod pocztowy',
             countries: {
+                BR: 'brazylijski',
                 CA: 'kanadyski',
                 DK: 'duński',
                 GB: 'brytyjski',

+ 1 - 0
dist/js/language/pt_BR.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'O código postal do país %s não é suportado',
             country: 'Por favor insira um código postal %s válido',
             countries: {
+                BR: 'Código postal Brasileiro',
                 CA: 'Código postal Canadense',
                 DK: 'Código postal Dinamarquês',
                 GB: 'Código postal do Reino Unido',

+ 1 - 0
dist/js/language/tr_TR.js

@@ -323,6 +323,7 @@
             countryNotSupported: '%s ülke kodu desteklenmemektedir',
             country: 'Lütfen geçerli bir %s',
             countries: {
+                BR: 'Brezilyalı posta kodu',
                 CA: 'Kanada posta kodu',
                 DK: 'Danimarka posta kodu',
                 GB: 'İngiltere posta kodu',

+ 1 - 0
dist/js/language/vi_VN.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Mã quốc gia %s không được hỗ trợ',
             country: 'Vui lòng nhập %s',
             countries: {
+                BR: 'mã bưu điện của Brazil',
                 CA: 'mã bưu điện của Canada',
                 DK: 'mã bưu điện của Đan Mạch',
                 GB: 'mã bưu điện của Vương quốc Anh',

+ 1 - 0
dist/js/language/zh_CN.js

@@ -323,6 +323,7 @@
             countryNotSupported: '不支援该国家代码%s',
             country: '请输入有效的 %s',
             countries: {
+                BR: '巴西 邮政编码',
                 CA: '加拿大 邮政编码',
                 DK: '丹麦 邮政编码',
                 GB: '英国 邮政编码',

+ 1 - 0
dist/js/language/zh_TW.js

@@ -323,6 +323,7 @@
             countryNotSupported: '不支援該國家代碼 %s',
             country: '請輸入有效的 %s',
             countries: {
+                BR: '巴西 郵政編碼',
                 CA: '加拿大 郵政編碼',
                 DK: '丹麥 郵政編碼',
                 GB: '英國 郵政編碼',

+ 1 - 0
src/js/language/be_NL.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'De land code %s is niet ondersteund',
             country: 'Please enter a valid %s',
             countries: {
+                BR: 'Braziliaans postcode',
                 CA: 'Canadeese postcode',
                 DK: 'Deense postcode',
                 GB: 'Engelse postcode',

+ 1 - 0
src/js/language/bg_BG.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Кода на държавата %s не се поддържа',
             country: 'Моля, въведете валиден %s',
             countries: {
+                BR: 'Бразилска пощенски код',
                 CA: 'Канадски пощенски код',
                 DK: 'Датски пощенски код',
                 GB: 'Пощенски код Великобритания',

+ 1 - 0
src/js/language/cs_CZ.js

@@ -323,6 +323,7 @@
             countryNotSupported: '%s není podporované',
             country: 'Prosím zadejte správné %s',
             countries: {
+                BR: 'Brazílii PSČ',
                 CA: 'Kanadské PSČ',
                 DK: 'Dánské PSČ',
                 GB: 'PSČ Velké Británie',

+ 1 - 0
src/js/language/da_DK.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Landekoden %s understøttes desværre ikke',
             country: 'Udfyld venligst dette felt med et gyldigt %s',
             countries: {
+                BR: 'brasiliansk postnummer',
                 CA: 'canadisk postnummer',
                 DK: 'dansk postnummer',
                 GB: 'engelsk postnummer',

+ 1 - 0
src/js/language/de_DE.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Der Ländercode %s wird nicht unterstützt',
             country: 'Bitte gültigen Code %s eingeben',
             countries: {
+                BR: 'Brasilianisch Postleitzahl',
                 CA: 'Kanadische Postleitzahl',
                 DK: 'Dänische Postleitzahl',
                 GB: 'Englische Postleitzahl',

+ 1 - 0
src/js/language/en_US.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'The country code %s is not supported',
             country: 'Please enter a valid %s',
             countries: {
+                BR: 'Brazilian postal code',
                 CA: 'Canadian postal code',
                 DK: 'Danish postal code',
                 GB: 'United Kingdom postal code',

+ 1 - 0
src/js/language/es_CL.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'El código del país %s no está soportado',
             country: 'Por favor ingrese un %s válido',
             countries: {
+                BR: 'código postal Brasileño',
                 CA: 'código postal Canadiense',
                 DK: 'código postal Danés',
                 GB: 'código postal Británico',

+ 1 - 0
src/js/language/es_ES.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'El código del país %s no está soportado',
             country: 'Por favor introduce un %s válido',
             countries: {
+                BR: 'código postal Brasileño',
                 CA: 'código postal Canadiense',
                 DK: 'código postal Danés',
                 GB: 'código postal Británico',

+ 1 - 0
src/js/language/fr_FR.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Le code de pays %s n\'est pas accepté',
             country: 'Veuillez fournir un %s valide',
             countries: {
+                BR: 'code postal brésilien',
                 CA: 'code postal canadien',
                 DK: 'code postal dannois',
                 GB: 'code postal anglais',

+ 1 - 0
src/js/language/gr_EL.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Ο κωδικός χώρας %s δεν υποστηρίζεται',
             country: 'Παρακαλώ εισάγετε ένα έγκυρο %s',
             countries: {
+                BR: 'ταχυδρομικό κώδικα Βραζιλίας',
                 CA: 'ταχυδρομικό κώδικα Καναδά',
                 DK: 'ταχυδρομικό κώδικα Δανίας',
                 GB: 'ταχυδρομικό κώδικα Ηνωμένου Βασιλείου',

+ 1 - 0
src/js/language/hu_HU.js

@@ -323,6 +323,7 @@
             countryNotSupported: '%s - nem támogatott ország',
             country: 'Kérlek, hogy helyes %s irányítószámot adj meg',
             countries: {
+                BR: 'brazil',
                 CA: 'kanadai',
                 DK: 'dán',
                 GB: 'Egyesült Királyság beli',

+ 9 - 8
src/js/language/it_IT.js

@@ -323,14 +323,15 @@
             countryNotSupported: 'Il codice nazione %s non e supportato',
             country: 'Si prega di inserire un valido  %s',
             countries: {
-                'CA': 'Codice postale Canadese',
-                'DK': 'Codice postale Danese',
-                'GB': 'Codice postale del Regno Unito',
-                'IT': 'Codice postale Italiano',
-                'NL': 'Codice postale Olandese',
-                'SE': 'Codice postale Svizzero',
-                'SG': 'Codice postale di Singapore',
-                'US': 'Codice postale US'
+                BR: 'Codice postale Brasiliano',
+                CA: 'Codice postale Canadese',
+                DK: 'Codice postale Danese',
+                GB: 'Codice postale del Regno Unito',
+                IT: 'Codice postale Italiano',
+                NL: 'Codice postale Olandese',
+                SE: 'Codice postale Svizzero',
+                SG: 'Codice postale di Singapore',
+                US: 'Codice postale US'
             }
         }
     });

+ 1 - 0
src/js/language/pl_PL.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Kod kraju %s nie jest obsługiwany',
             country: 'Wprowadź poprawny %s kod pocztowy',
             countries: {
+                BR: 'brazylijski',
                 CA: 'kanadyski',
                 DK: 'duński',
                 GB: 'brytyjski',

+ 1 - 0
src/js/language/pt_BR.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'O código postal do país %s não é suportado',
             country: 'Por favor insira um código postal %s válido',
             countries: {
+                BR: 'Código postal Brasileiro',
                 CA: 'Código postal Canadense',
                 DK: 'Código postal Dinamarquês',
                 GB: 'Código postal do Reino Unido',

+ 1 - 0
src/js/language/tr_TR.js

@@ -323,6 +323,7 @@
             countryNotSupported: '%s ülke kodu desteklenmemektedir',
             country: 'Lütfen geçerli bir %s',
             countries: {
+                BR: 'Brezilyalı posta kodu',
                 CA: 'Kanada posta kodu',
                 DK: 'Danimarka posta kodu',
                 GB: 'İngiltere posta kodu',

+ 1 - 0
src/js/language/vi_VN.js

@@ -323,6 +323,7 @@
             countryNotSupported: 'Mã quốc gia %s không được hỗ trợ',
             country: 'Vui lòng nhập %s',
             countries: {
+                BR: 'mã bưu điện của Brazil',
                 CA: 'mã bưu điện của Canada',
                 DK: 'mã bưu điện của Đan Mạch',
                 GB: 'mã bưu điện của Vương quốc Anh',

+ 1 - 0
src/js/language/zh_CN.js

@@ -323,6 +323,7 @@
             countryNotSupported: '不支援该国家代码%s',
             country: '请输入有效的 %s',
             countries: {
+                BR: '巴西 邮政编码',
                 CA: '加拿大 邮政编码',
                 DK: '丹麦 邮政编码',
                 GB: '英国 邮政编码',

+ 1 - 0
src/js/language/zh_TW.js

@@ -323,6 +323,7 @@
             countryNotSupported: '不支援該國家代碼 %s',
             country: '請輸入有效的 %s',
             countries: {
+                BR: '巴西 郵政編碼',
                 CA: '加拿大 郵政編碼',
                 DK: '丹麥 郵政編碼',
                 GB: '英國 郵政編碼',

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

@@ -4,6 +4,7 @@
         countryNotSupported: 'The country code %s is not supported',
         country: 'Please enter a valid %s',
         countries: {
+            BR: 'Brazilian postal code',
             CA: 'Canadian postal code',
             DK: 'Danish postal code',
             GB: 'United Kingdom postal code',
@@ -11,8 +12,7 @@
             NL: 'Dutch postal code',
             SE: 'Swiss postal code',
             SG: 'Singapore postal code',
-            US: 'US zip code',
-            BR: 'Brazilian postal code'
+            US: 'US zip code'
         }
     });
 
@@ -22,7 +22,7 @@
             country: 'country'
         },
 
-        COUNTRY_CODES: ['CA', 'DK', 'GB', 'IT', 'NL', 'SE', 'SG', 'US', 'BR'],
+        COUNTRY_CODES: ['BR', 'CA', 'DK', 'GB', 'IT', 'NL', 'SE', 'SG', 'US'],
 
         /**
          * Return true if and only if the input value is a valid country zip code
@@ -35,16 +35,6 @@
          *
          * The country can be defined by:
          * - An ISO 3166 country code
-         * Currently it supports the following countries:
-         *      - US (United States)
-         *      - CA (Canada)
-         *      - DK (Denmark)
-         *      - GB (United Kingdom)
-         *      - IT (Italy)
-         *      - NL (Netherlands)
-         *      - SE (Sweden)
-         *      - SG (Singapore)
-         *
          * - Name of field which its value defines the country code
          * - Name of callback function that returns the country code
          * - A callback function that returns the country code
@@ -76,6 +66,10 @@
             var isValid = false;
             country = country.toUpperCase();
             switch (country) {
+                case 'BR':
+                    isValid = /^(\d{2})([\.]?)(\d{3})([\-]?)(\d{3})$/.test(value);
+                    break;
+
                 case 'CA':
                     isValid = /^(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|X|Y){1}[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}\s?[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}[0-9]{1}$/i.test(value);
                     break;
@@ -106,10 +100,6 @@
                     isValid = /^([0][1-9]|[1-6][0-9]|[7]([0-3]|[5-9])|[8][0-2])(\d{4})$/i.test(value);
                     break;
                     
-                case 'BR':
-                    isValid = /^(\d{2})([\.]?)(\d{3})([\-]?)(\d{3})$/.test(value);
-                    break;
-
                 case 'US':
                 /* falls through */
                 default: