ソースを参照

#480: Add verbose option, thanks to @mbezhanov

Phuoc Nguyen 11 年 前
コミット
505e1b27ee

+ 1 - 0
CHANGELOG.md

@@ -3,6 +3,7 @@
 ## v0.5.2 (not released yet)
 
 __New Features__
+* [#480](https://github.com/nghuuphuoc/bootstrapvalidator/pull/480): Add ```verbose``` option, thanks to [@mbezhanov](https://github.com/mbezhanov)
 * [#542](https://github.com/nghuuphuoc/bootstrapvalidator/issues/542), [#666](https://github.com/nghuuphuoc/bootstrapvalidator/pull/666): Add blank validator, thanks to [@bermo](https://github.com/bermo)
 * [#617](https://github.com/nghuuphuoc/bootstrapvalidator/issues/617): Add ```init``` and ```destroy``` methods to validator
 * [#724](https://github.com/nghuuphuoc/bootstrapvalidator/pull/724): Add Venezuelan VAT number (RIF) validator, thanks to [@paquitodev](https://github.com/paquitodev)

+ 1 - 0
CONTRIBUTORS.md

@@ -50,6 +50,7 @@ I would like to give big thanks to the following contributors:
 * [@marcuscarvalho6](https://github.com/marcuscarvalho6)
 * [@mattrick](https://github.com/mattrick)
 * [@MartinDevillers](https://github.com/MartinDevillers)
+* [@mbezhanov](https://github.com/mbezhanov)
 * [@mike1e](https://github.com/mike1e)
 * [@mraiur](https://github.com/mraiur)
 * [@MrC0mm0n](https://github.com/MrC0mm0n)

+ 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.2-dev, built on 2014-08-29 11:38:36 AM
+ * @version     v0.5.2-dev, built on 2014-08-29 4:10:46 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 47 - 24
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.2-dev, built on 2014-08-29 11:38:36 AM
+ * @version     v0.5.2-dev, built on 2014-08-29 4:10:46 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -54,22 +54,7 @@
         _init: function() {
             var that    = this,
                 options = {
-                    excluded:       this.$form.attr('data-bv-excluded'),
-                    trigger:        this.$form.attr('data-bv-trigger'),
-                    message:        this.$form.attr('data-bv-message'),
                     container:      this.$form.attr('data-bv-container'),
-                    group:          this.$form.attr('data-bv-group'),
-                    submitButtons:  this.$form.attr('data-bv-submitbuttons'),
-                    threshold:      this.$form.attr('data-bv-threshold'),
-                    live:           this.$form.attr('data-bv-live'),
-                    onSuccess:      this.$form.attr('data-bv-onsuccess'),
-                    onError:        this.$form.attr('data-bv-onerror'),
-                    fields:         {},
-                    feedbackIcons: {
-                        valid:      this.$form.attr('data-bv-feedbackicons-valid'),
-                        invalid:    this.$form.attr('data-bv-feedbackicons-invalid'),
-                        validating: this.$form.attr('data-bv-feedbackicons-validating')
-                    },
                     events: {
                         formInit:         this.$form.attr('data-bv-events-form-init'),
                         formError:        this.$form.attr('data-bv-events-form-error'),
@@ -82,7 +67,23 @@
                         fieldStatus:      this.$form.attr('data-bv-events-field-status'),
                         validatorError:   this.$form.attr('data-bv-events-validator-error'),
                         validatorSuccess: this.$form.attr('data-bv-events-validator-success')
-                    }
+                    },
+                    excluded:       this.$form.attr('data-bv-excluded'),
+                    feedbackIcons: {
+                        valid:      this.$form.attr('data-bv-feedbackicons-valid'),
+                        invalid:    this.$form.attr('data-bv-feedbackicons-invalid'),
+                        validating: this.$form.attr('data-bv-feedbackicons-validating')
+                    },
+                    group:          this.$form.attr('data-bv-group'),
+                    live:           this.$form.attr('data-bv-live'),
+                    message:        this.$form.attr('data-bv-message'),
+                    onError:        this.$form.attr('data-bv-onerror'),
+                    onSuccess:      this.$form.attr('data-bv-onsuccess'),
+                    submitButtons:  this.$form.attr('data-bv-submitbuttons'),
+                    threshold:      this.$form.attr('data-bv-threshold'),
+                    trigger:        this.$form.attr('data-bv-trigger'),
+                    verbose:        this.$form.attr('data-bv-verbose'),
+                    fields:         {}
                 };
 
             this.$form
@@ -199,17 +200,18 @@
             }
 
             var opts = {
+                    container:     $field.attr('data-bv-container'),
                     excluded:      $field.attr('data-bv-excluded'),
                     feedbackIcons: $field.attr('data-bv-feedbackicons'),
-                    trigger:       $field.attr('data-bv-trigger'),
-                    message:       $field.attr('data-bv-message'),
-                    container:     $field.attr('data-bv-container'),
                     group:         $field.attr('data-bv-group'),
-                    selector:      $field.attr('data-bv-selector'),
-                    threshold:     $field.attr('data-bv-threshold'),
+                    message:       $field.attr('data-bv-message'),
+                    onError:       $field.attr('data-bv-onerror'),
                     onStatus:      $field.attr('data-bv-onstatus'),
                     onSuccess:     $field.attr('data-bv-onsuccess'),
-                    onError:       $field.attr('data-bv-onerror'),
+                    selector:      $field.attr('data-bv-selector'),
+                    threshold:     $field.attr('data-bv-threshold'),
+                    trigger:       $field.attr('data-bv-trigger'),
+                    verbose:       $field.attr('data-bv-verbose'),
                     validators:    validators
                 },
                 emptyOptions    = $.isEmptyObject(opts),        // Check if the field options are set using HTML attributes
@@ -764,6 +766,7 @@
                 total      = ('radio' === type || 'checkbox' === type) ? 1 : fields.length,
                 updateAll  = ('radio' === type || 'checkbox' === type),
                 validators = this.options.fields[field].validators,
+                verbose    = this.options.fields[field].verbose === 'true' || this.options.fields[field].verbose === true || this.options.verbose === 'true' || this.options.verbose === true,
                 validatorName,
                 validateResult;
 
@@ -773,10 +776,14 @@
                     continue;
                 }
 
+                var stop = false;
                 for (validatorName in validators) {
                     if ($field.data('bv.dfs.' + validatorName)) {
                         $field.data('bv.dfs.' + validatorName).reject();
                     }
+                    if (stop) {
+                        break;
+                    }
 
                     // Don't validate field if it is already done
                     var result = $field.data('bv.result.' + validatorName);
@@ -808,6 +815,8 @@
                             if (isValid && that._submitIfValid === true) {
                                 // If a remote validator returns true and the form is ready to submit, then do it
                                 that._submit();
+                            } else if (!isValid && !verbose) {
+                                stop = true;
                             }
                         });
                     }
@@ -815,10 +824,16 @@
                     else if ('object' === typeof validateResult && validateResult.valid !== undefined && validateResult.message !== undefined) {
                         this.updateMessage(updateAll ? field : $field, validatorName, validateResult.message);
                         this.updateStatus(updateAll ? field : $field, validateResult.valid ? this.STATUS_VALID : this.STATUS_INVALID, validatorName);
+                        if (!validateResult.valid && !verbose) {
+                            break;
+                        }
                     }
                     // ... or a boolean value
                     else if ('boolean' === typeof validateResult) {
                         this.updateStatus(updateAll ? field : $field, validateResult ? this.STATUS_VALID : this.STATUS_INVALID, validatorName);
+                        if (!validateResult && !verbose) {
+                            break;
+                        }
                     }
                 }
             }
@@ -1705,7 +1720,15 @@
             fieldStatus: 'status.field.bv',
             validatorError: 'error.validator.bv',
             validatorSuccess: 'success.validator.bv'
-        }
+        },
+        
+        // Whether to be verbose when validating a field or not.
+        // Possible values:
+        // - true:  when a field has multiple validators, all of them will be checked, and respectively - if errors occur in
+        //          multiple validators, all of them will be displayed to the user
+        // - false: when a field has multiple validators, validation for this field will be terminated upon the first encountered error.
+        //          Thus, only the very first error message related to this field will be displayed to the user
+        verbose: true
     };
 
     // Available validators

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


+ 33 - 24
src/js/bootstrapValidator.js

@@ -53,22 +53,7 @@
         _init: function() {
             var that    = this,
                 options = {
-                    excluded:       this.$form.attr('data-bv-excluded'),
-                    trigger:        this.$form.attr('data-bv-trigger'),
-                    message:        this.$form.attr('data-bv-message'),
                     container:      this.$form.attr('data-bv-container'),
-                    group:          this.$form.attr('data-bv-group'),
-                    submitButtons:  this.$form.attr('data-bv-submitbuttons'),
-                    threshold:      this.$form.attr('data-bv-threshold'),
-                    live:           this.$form.attr('data-bv-live'),
-                    onSuccess:      this.$form.attr('data-bv-onsuccess'),
-                    onError:        this.$form.attr('data-bv-onerror'),
-                    fields:         {},
-                    feedbackIcons: {
-                        valid:      this.$form.attr('data-bv-feedbackicons-valid'),
-                        invalid:    this.$form.attr('data-bv-feedbackicons-invalid'),
-                        validating: this.$form.attr('data-bv-feedbackicons-validating')
-                    },
                     events: {
                         formInit:         this.$form.attr('data-bv-events-form-init'),
                         formError:        this.$form.attr('data-bv-events-form-error'),
@@ -81,7 +66,23 @@
                         fieldStatus:      this.$form.attr('data-bv-events-field-status'),
                         validatorError:   this.$form.attr('data-bv-events-validator-error'),
                         validatorSuccess: this.$form.attr('data-bv-events-validator-success')
-                    }
+                    },
+                    excluded:       this.$form.attr('data-bv-excluded'),
+                    feedbackIcons: {
+                        valid:      this.$form.attr('data-bv-feedbackicons-valid'),
+                        invalid:    this.$form.attr('data-bv-feedbackicons-invalid'),
+                        validating: this.$form.attr('data-bv-feedbackicons-validating')
+                    },
+                    group:          this.$form.attr('data-bv-group'),
+                    live:           this.$form.attr('data-bv-live'),
+                    message:        this.$form.attr('data-bv-message'),
+                    onError:        this.$form.attr('data-bv-onerror'),
+                    onSuccess:      this.$form.attr('data-bv-onsuccess'),
+                    submitButtons:  this.$form.attr('data-bv-submitbuttons'),
+                    threshold:      this.$form.attr('data-bv-threshold'),
+                    trigger:        this.$form.attr('data-bv-trigger'),
+                    verbose:        this.$form.attr('data-bv-verbose'),
+                    fields:         {}
                 };
 
             this.$form
@@ -198,17 +199,18 @@
             }
 
             var opts = {
+                    container:     $field.attr('data-bv-container'),
                     excluded:      $field.attr('data-bv-excluded'),
                     feedbackIcons: $field.attr('data-bv-feedbackicons'),
-                    trigger:       $field.attr('data-bv-trigger'),
-                    message:       $field.attr('data-bv-message'),
-                    container:     $field.attr('data-bv-container'),
                     group:         $field.attr('data-bv-group'),
-                    selector:      $field.attr('data-bv-selector'),
-                    threshold:     $field.attr('data-bv-threshold'),
+                    message:       $field.attr('data-bv-message'),
+                    onError:       $field.attr('data-bv-onerror'),
                     onStatus:      $field.attr('data-bv-onstatus'),
                     onSuccess:     $field.attr('data-bv-onsuccess'),
-                    onError:       $field.attr('data-bv-onerror'),
+                    selector:      $field.attr('data-bv-selector'),
+                    threshold:     $field.attr('data-bv-threshold'),
+                    trigger:       $field.attr('data-bv-trigger'),
+                    verbose:       $field.attr('data-bv-verbose'),
                     validators:    validators
                 },
                 emptyOptions    = $.isEmptyObject(opts),        // Check if the field options are set using HTML attributes
@@ -763,6 +765,7 @@
                 total      = ('radio' === type || 'checkbox' === type) ? 1 : fields.length,
                 updateAll  = ('radio' === type || 'checkbox' === type),
                 validators = this.options.fields[field].validators,
+                verbose    = this.options.fields[field].verbose === 'true' || this.options.fields[field].verbose === true || this.options.verbose === 'true' || this.options.verbose === true,
                 validatorName,
                 validateResult;
 
@@ -772,10 +775,14 @@
                     continue;
                 }
 
+                var stop = false;
                 for (validatorName in validators) {
                     if ($field.data('bv.dfs.' + validatorName)) {
                         $field.data('bv.dfs.' + validatorName).reject();
                     }
+                    if (stop) {
+                        break;
+                    }
 
                     // Don't validate field if it is already done
                     var result = $field.data('bv.result.' + validatorName);
@@ -807,6 +814,8 @@
                             if (isValid && that._submitIfValid === true) {
                                 // If a remote validator returns true and the form is ready to submit, then do it
                                 that._submit();
+                            } else if (!isValid && !verbose) {
+                                stop = true;
                             }
                         });
                     }
@@ -814,14 +823,14 @@
                     else if ('object' === typeof validateResult && validateResult.valid !== undefined && validateResult.message !== undefined) {
                         this.updateMessage(updateAll ? field : $field, validatorName, validateResult.message);
                         this.updateStatus(updateAll ? field : $field, validateResult.valid ? this.STATUS_VALID : this.STATUS_INVALID, validatorName);
-                        if (!validateResult.valid && !this.options.verbose) {
+                        if (!validateResult.valid && !verbose) {
                             break;
                         }
                     }
                     // ... or a boolean value
                     else if ('boolean' === typeof validateResult) {
                         this.updateStatus(updateAll ? field : $field, validateResult ? this.STATUS_VALID : this.STATUS_INVALID, validatorName);
-                        if (!validateResult && !this.options.verbose) {
+                        if (!validateResult && !verbose) {
                             break;
                         }
                     }

+ 0 - 15
src/js/validator/allowedValue.js

@@ -1,15 +0,0 @@
-(function($) {
-    $.fn.bootstrapValidator.validators.allowedValue = {
-        /**
-         * @param {BootstrapValidator} validator The validator plugin instance
-         * @param {jQuery} $field The jQuery object represents the field element
-         * @param {Object} options The validator options
-         * @returns {boolean}
-         */
-        validate: function(validator, $field, options) {
-			var value = $field.val();
-			var allowedValues = (options.allowedValues !== undefined) ? options.allowedValues : [];
-			return ($.inArray(value, allowedValues) > -1 ? true : false);
-        }
-    };
-}(window.jQuery));

+ 144 - 0
test/spec.js

@@ -1859,6 +1859,150 @@ describe('message', function() {
     });
 });
 
+describe('verbose option', function() {
+    beforeEach(function() {
+        $([
+            '<form class="form-horizontal" id="verboseForm">',
+                '<div class="form-group">',
+                    '<input type="text" name="fullName" class="form-control" ',
+                        'required data-bv-notempty-message="The full name is required and cannot be empty" ',
+                        'data-bv-regexp="true" data-bv-regexp-regexp="^[a-zA-Z\\s]+$" data-bv-regexp-message="The full name can only consist of alphabetical, number, and space" ',
+                        'data-bv-stringlength="true" data-bv-stringlength-min="8" data-bv-stringlength-max="40" data-bv-stringlength-message="The full name must be more than 8 and less than 40 characters long" ',
+                    '/>',
+                '</div>',
+            '</form>'
+        ].join('\n')).appendTo('body');
+
+        // The order of validators are alphabetical:
+        // - notEmpty
+        // - regexp
+        // - stringLength
+    });
+
+    afterEach(function() {
+        $('#verboseForm').bootstrapValidator('destroy').remove();
+    });
+
+    it('set data-bv-verbose="false" for form', function() {
+        var bv        = $('#verboseForm').attr('data-bv-verbose', 'false').bootstrapValidator().data('bootstrapValidator'),
+            $fullName = bv.getFieldElements('fullName'),
+            messages;
+
+        $fullName.val('');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-notempty-message'));
+
+        bv.resetForm();
+        $fullName.val('Special@#$');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-regexp-message'));
+
+        bv.resetForm();
+        $fullName.val('Full');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-stringlength-message'));
+    });
+
+    it('set data-bv-verbose="false" for field', function() {
+        var bv        = $('#verboseForm')
+                            .attr('data-bv-verbose', 'true')
+                            .find('[name="fullName"]')
+                                .attr('data-bv-verbose', 'false')
+                                .end()
+                            .bootstrapValidator().data('bootstrapValidator'),
+            $fullName = bv.getFieldElements('fullName'),
+            messages;
+
+        $fullName.val('');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-notempty-message'));
+
+        bv.resetForm();
+        $fullName.val('Special@#$');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-regexp-message'));
+
+        bv.resetForm();
+        $fullName.val('Full');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-stringlength-message'));
+    });
+
+    it('set verbose: "false" for form', function() {
+        var bv        = $('#verboseForm').bootstrapValidator({ verbose: false }).data('bootstrapValidator'),
+            $fullName = bv.getFieldElements('fullName'),
+            messages;
+
+        $fullName.val('');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-notempty-message'));
+
+        bv.resetForm();
+        $fullName.val('Special@#$');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-regexp-message'));
+
+        bv.resetForm();
+        $fullName.val('Full');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-stringlength-message'));
+    });
+
+    it('set verbose: "false" for field', function() {
+        var bv        = $('#verboseForm')
+                            .attr('data-bv-verbose', 'true')
+                            .bootstrapValidator({
+                                verbose: true,
+                                fields: {
+                                    fullName: {
+                                        verbose: false
+                                    }
+                                }
+                            })
+                            .data('bootstrapValidator'),
+            $fullName = bv.getFieldElements('fullName'),
+            messages;
+
+        $fullName.val('');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-notempty-message'));
+
+        bv.resetForm();
+        $fullName.val('Special@#$');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-regexp-message'));
+
+        bv.resetForm();
+        $fullName.val('Full');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-stringlength-message'));
+    });
+});
+
 function betweenCompareMin() {
     var compareTo = $('#betweenForm').find('[name="minAge"]').val();
     $('#msgMin').html('betweenCompareMin() called; compare to ' + compareTo);

+ 143 - 0
test/spec/verbose.js

@@ -0,0 +1,143 @@
+describe('verbose option', function() {
+    beforeEach(function() {
+        $([
+            '<form class="form-horizontal" id="verboseForm">',
+                '<div class="form-group">',
+                    '<input type="text" name="fullName" class="form-control" ',
+                        'required data-bv-notempty-message="The full name is required and cannot be empty" ',
+                        'data-bv-regexp="true" data-bv-regexp-regexp="^[a-zA-Z\\s]+$" data-bv-regexp-message="The full name can only consist of alphabetical, number, and space" ',
+                        'data-bv-stringlength="true" data-bv-stringlength-min="8" data-bv-stringlength-max="40" data-bv-stringlength-message="The full name must be more than 8 and less than 40 characters long" ',
+                    '/>',
+                '</div>',
+            '</form>'
+        ].join('\n')).appendTo('body');
+
+        // The order of validators are alphabetical:
+        // - notEmpty
+        // - regexp
+        // - stringLength
+    });
+
+    afterEach(function() {
+        $('#verboseForm').bootstrapValidator('destroy').remove();
+    });
+
+    it('set data-bv-verbose="false" for form', function() {
+        var bv        = $('#verboseForm').attr('data-bv-verbose', 'false').bootstrapValidator().data('bootstrapValidator'),
+            $fullName = bv.getFieldElements('fullName'),
+            messages;
+
+        $fullName.val('');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-notempty-message'));
+
+        bv.resetForm();
+        $fullName.val('Special@#$');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-regexp-message'));
+
+        bv.resetForm();
+        $fullName.val('Full');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-stringlength-message'));
+    });
+
+    it('set data-bv-verbose="false" for field', function() {
+        var bv        = $('#verboseForm')
+                            .attr('data-bv-verbose', 'true')
+                            .find('[name="fullName"]')
+                                .attr('data-bv-verbose', 'false')
+                                .end()
+                            .bootstrapValidator().data('bootstrapValidator'),
+            $fullName = bv.getFieldElements('fullName'),
+            messages;
+
+        $fullName.val('');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-notempty-message'));
+
+        bv.resetForm();
+        $fullName.val('Special@#$');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-regexp-message'));
+
+        bv.resetForm();
+        $fullName.val('Full');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-stringlength-message'));
+    });
+
+    it('set verbose: "false" for form', function() {
+        var bv        = $('#verboseForm').bootstrapValidator({ verbose: false }).data('bootstrapValidator'),
+            $fullName = bv.getFieldElements('fullName'),
+            messages;
+
+        $fullName.val('');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-notempty-message'));
+
+        bv.resetForm();
+        $fullName.val('Special@#$');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-regexp-message'));
+
+        bv.resetForm();
+        $fullName.val('Full');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-stringlength-message'));
+    });
+
+    it('set verbose: "false" for field', function() {
+        var bv        = $('#verboseForm')
+                            .attr('data-bv-verbose', 'true')
+                            .bootstrapValidator({
+                                verbose: true,
+                                fields: {
+                                    fullName: {
+                                        verbose: false
+                                    }
+                                }
+                            })
+                            .data('bootstrapValidator'),
+            $fullName = bv.getFieldElements('fullName'),
+            messages;
+
+        $fullName.val('');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-notempty-message'));
+
+        bv.resetForm();
+        $fullName.val('Special@#$');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-regexp-message'));
+
+        bv.resetForm();
+        $fullName.val('Full');
+        bv.validate();
+        messages = bv.getMessages('fullName');
+        expect(messages.length).toEqual(1);
+        expect(messages[0]).toEqual($fullName.attr('data-bv-stringlength-message'));
+    });
+});