|
|
@@ -1024,6 +1024,8 @@ describe('event field trigger with default events', function() {
|
|
|
});
|
|
|
|
|
|
describe('event form trigger with events changed', function() {
|
|
|
+ var defaultOptions = $.fn.bootstrapValidator.DEFAULT_OPTIONS;
|
|
|
+
|
|
|
beforeEach(function() {
|
|
|
$.fn.bootstrapValidator.DEFAULT_OPTIONS = $.extend({}, $.fn.bootstrapValidator.DEFAULT_OPTIONS, {
|
|
|
events: {
|
|
|
@@ -1070,6 +1072,7 @@ describe('event form trigger with events changed', function() {
|
|
|
});
|
|
|
|
|
|
afterEach(function() {
|
|
|
+ $.fn.bootstrapValidator.DEFAULT_OPTIONS = defaultOptions;
|
|
|
$('#eventForm2').bootstrapValidator('destroy').remove();
|
|
|
});
|
|
|
|
|
|
@@ -1097,7 +1100,9 @@ describe('event form trigger with events changed', function() {
|
|
|
});
|
|
|
|
|
|
describe('event field trigger with events changed', function() {
|
|
|
- beforeEach(function () {
|
|
|
+ var defaultOptions = $.fn.bootstrapValidator.DEFAULT_OPTIONS;
|
|
|
+
|
|
|
+ beforeEach(function() {
|
|
|
$.fn.bootstrapValidator.DEFAULT_OPTIONS = $.extend({}, $.fn.bootstrapValidator.DEFAULT_OPTIONS, {
|
|
|
events: {
|
|
|
formInit: 'init.form.bv',
|
|
|
@@ -1143,6 +1148,7 @@ describe('event field trigger with events changed', function() {
|
|
|
});
|
|
|
|
|
|
afterEach(function() {
|
|
|
+ $.fn.bootstrapValidator.DEFAULT_OPTIONS = defaultOptions;
|
|
|
$('#eventForm4').bootstrapValidator('destroy').remove();
|
|
|
});
|
|
|
|
|
|
@@ -2014,7 +2020,11 @@ describe('verbose option', function() {
|
|
|
});
|
|
|
|
|
|
it('set data-bv-verbose="false" for form', function() {
|
|
|
- var bv = $('#verboseForm').attr('data-bv-verbose', 'false').bootstrapValidator().data('bootstrapValidator'),
|
|
|
+ var bv = $('#verboseForm')
|
|
|
+ .attr('data-bv-verbose', 'false')
|
|
|
+ .bootstrapValidator('destroy')
|
|
|
+ .bootstrapValidator()
|
|
|
+ .data('bootstrapValidator'),
|
|
|
$fullName = bv.getFieldElements('fullName'),
|
|
|
messages;
|
|
|
|
|
|
@@ -2025,7 +2035,7 @@ describe('verbose option', function() {
|
|
|
expect(messages[0]).toEqual($fullName.attr('data-bv-notempty-message'));
|
|
|
|
|
|
bv.resetForm();
|
|
|
- $fullName.val('Special@#$');
|
|
|
+ $fullName.val('Spe@#$');
|
|
|
bv.validate();
|
|
|
messages = bv.getMessages('fullName');
|
|
|
expect(messages.length).toEqual(1);
|
|
|
@@ -2045,7 +2055,9 @@ describe('verbose option', function() {
|
|
|
.find('[name="fullName"]')
|
|
|
.attr('data-bv-verbose', 'false')
|
|
|
.end()
|
|
|
- .bootstrapValidator().data('bootstrapValidator'),
|
|
|
+ .bootstrapValidator('destroy')
|
|
|
+ .bootstrapValidator()
|
|
|
+ .data('bootstrapValidator'),
|
|
|
$fullName = bv.getFieldElements('fullName'),
|
|
|
messages;
|
|
|
|
|
|
@@ -2056,7 +2068,7 @@ describe('verbose option', function() {
|
|
|
expect(messages[0]).toEqual($fullName.attr('data-bv-notempty-message'));
|
|
|
|
|
|
bv.resetForm();
|
|
|
- $fullName.val('Special@#$');
|
|
|
+ $fullName.val('Spe@#$');
|
|
|
bv.validate();
|
|
|
messages = bv.getMessages('fullName');
|
|
|
expect(messages.length).toEqual(1);
|
|
|
@@ -2071,7 +2083,10 @@ describe('verbose option', function() {
|
|
|
});
|
|
|
|
|
|
it('set verbose: "false" for form', function() {
|
|
|
- var bv = $('#verboseForm').bootstrapValidator({ verbose: false }).data('bootstrapValidator'),
|
|
|
+ var bv = $('#verboseForm')
|
|
|
+ .bootstrapValidator('destroy')
|
|
|
+ .bootstrapValidator({ verbose: false })
|
|
|
+ .data('bootstrapValidator'),
|
|
|
$fullName = bv.getFieldElements('fullName'),
|
|
|
messages;
|
|
|
|
|
|
@@ -2082,7 +2097,7 @@ describe('verbose option', function() {
|
|
|
expect(messages[0]).toEqual($fullName.attr('data-bv-notempty-message'));
|
|
|
|
|
|
bv.resetForm();
|
|
|
- $fullName.val('Special@#$');
|
|
|
+ $fullName.val('Spe@#$');
|
|
|
bv.validate();
|
|
|
messages = bv.getMessages('fullName');
|
|
|
expect(messages.length).toEqual(1);
|
|
|
@@ -2096,9 +2111,11 @@ describe('verbose option', function() {
|
|
|
expect(messages[0]).toEqual($fullName.attr('data-bv-stringlength-message'));
|
|
|
});
|
|
|
|
|
|
+ // #1057
|
|
|
it('set verbose: "false" for field', function() {
|
|
|
var bv = $('#verboseForm')
|
|
|
.attr('data-bv-verbose', 'true')
|
|
|
+ .bootstrapValidator('destroy')
|
|
|
.bootstrapValidator({
|
|
|
verbose: true,
|
|
|
fields: {
|
|
|
@@ -2118,7 +2135,7 @@ describe('verbose option', function() {
|
|
|
expect(messages[0]).toEqual($fullName.attr('data-bv-notempty-message'));
|
|
|
|
|
|
bv.resetForm();
|
|
|
- $fullName.val('Special@#$');
|
|
|
+ $fullName.val('Spe@#$');
|
|
|
bv.validate();
|
|
|
messages = bv.getMessages('fullName');
|
|
|
expect(messages.length).toEqual(1);
|
|
|
@@ -2131,6 +2148,46 @@ describe('verbose option', function() {
|
|
|
expect(messages.length).toEqual(1);
|
|
|
expect(messages[0]).toEqual($fullName.attr('data-bv-stringlength-message'));
|
|
|
});
|
|
|
+
|
|
|
+ // #1055
|
|
|
+ it('trigger "error.field.bv" event', function() {
|
|
|
+ var validators = [], // Array of not passed validators
|
|
|
+ bv = $('#verboseForm')
|
|
|
+ .attr('data-bv-verbose', 'true')
|
|
|
+ .bootstrapValidator('destroy')
|
|
|
+ .bootstrapValidator({
|
|
|
+ verbose: true,
|
|
|
+ fields: {
|
|
|
+ fullName: {
|
|
|
+ verbose: false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .on('error.field.bv', function(e, data) {
|
|
|
+ validators.push(data.validator);
|
|
|
+ })
|
|
|
+ .data('bootstrapValidator'),
|
|
|
+ $fullName = bv.getFieldElements('fullName');
|
|
|
+
|
|
|
+ $fullName.val('');
|
|
|
+ bv.validate();
|
|
|
+ expect(validators.length).toEqual(1);
|
|
|
+ expect(validators[0]).toEqual('notEmpty');
|
|
|
+
|
|
|
+ validators = [];
|
|
|
+ bv.resetForm();
|
|
|
+ $fullName.val('Spe@#$');
|
|
|
+ bv.validate();
|
|
|
+ expect(validators.length).toEqual(1);
|
|
|
+ expect(validators[0]).toEqual('regexp');
|
|
|
+
|
|
|
+ validators = [];
|
|
|
+ bv.resetForm();
|
|
|
+ $fullName.val('Full');
|
|
|
+ bv.validate();
|
|
|
+ expect(validators.length).toEqual(1);
|
|
|
+ expect(validators[0]).toEqual('stringLength');
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
function betweenCompareMin() {
|