ソースを参照

#1048: Allow to use comma in dynamic option value

phuoc 11 年 前
コミット
ff698ae4bb

+ 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.3-dev, built on 2014-10-31 2:46:30 PM
+ * @version     v0.5.3-dev, built on 2014-11-01 5:18:27 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 33 - 14
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.3-dev, built on 2014-10-31 2:46:30 PM
+ * @version     v0.5.3-dev, built on 2014-11-01 5:18:27 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -2042,23 +2042,30 @@ if (typeof jQuery === 'undefined') {
                 return true;
             }
 
-			value = value.replace(',', '.');
+			value = this._format(value);
             if (!$.isNumeric(value)) {
                 return false;
             }
 
-            var min = $.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min),
-                max = $.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max);
+            var min      = $.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min),
+                max      = $.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max),
+                minValue = this._format(min),
+                maxValue = this._format(max);
+
             value = parseFloat(value);
 			return (options.inclusive === true || options.inclusive === undefined)
                     ? {
-                        valid: value >= min && value <= max,
+                        valid: value >= minValue && value <= maxValue,
                         message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.between['default'], [min, max])
                     }
                     : {
-                        valid: value > min  && value <  max,
+                        valid: value > minValue  && value <  maxValue,
                         message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.between.notInclusive, [min, max])
                     };
+        },
+
+        _format: function(value) {
+            return (value + '').replace(',', '.');
         }
     };
 }(window.jQuery));
@@ -3189,22 +3196,28 @@ if (typeof jQuery === 'undefined') {
                 return true;
             }
             
-            value = value.replace(',', '.');
+            value = this._format(value);
             if (!$.isNumeric(value)) {
                 return false;
             }
 
-            var compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value);
+            var compareTo      = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value),
+                compareToValue = this._format(compareTo);
+
             value = parseFloat(value);
 			return (options.inclusive === true || options.inclusive === undefined)
                     ? {
-                        valid: value >= compareTo,
+                        valid: value >= compareToValue,
                         message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.greaterThan['default'], compareTo)
                     }
                     : {
-                        valid: value > compareTo,
+                        valid: value > compareToValue,
                         message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.greaterThan.notInclusive, compareTo)
                     };
+        },
+
+        _format: function(value) {
+            return (value + '').replace(',', '.');
         }
     };
 }(window.jQuery));
@@ -5450,22 +5463,28 @@ if (typeof jQuery === 'undefined') {
                 return true;
             }
             
-			value = value.replace(',', '.');
+			value = this._format(value);
             if (!$.isNumeric(value)) {
                 return false;
             }
 
-            var compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value);
+            var compareTo      = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value),
+                compareToValue = this._format(compareTo);
+
             value = parseFloat(value);
             return (options.inclusive === true || options.inclusive === undefined)
                     ? {
-                        valid: value <= compareTo,
+                        valid: value <= compareToValue,
                         message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.lessThan['default'], compareTo)
                     }
                     : {
-                        valid: value < compareTo,
+                        valid: value < compareToValue,
                         message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.lessThan.notInclusive, compareTo)
                     };
+        },
+
+        _format: function(value) {
+            return (value + '').replace(',', '.');
         }
     };
 }(window.jQuery));

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


+ 12 - 5
src/js/validator/between.js

@@ -48,23 +48,30 @@
                 return true;
             }
 
-			value = value.replace(',', '.');
+			value = this._format(value);
             if (!$.isNumeric(value)) {
                 return false;
             }
 
-            var min = $.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min),
-                max = $.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max);
+            var min      = $.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min),
+                max      = $.isNumeric(options.max) ? options.max : validator.getDynamicOption($field, options.max),
+                minValue = this._format(min),
+                maxValue = this._format(max);
+
             value = parseFloat(value);
 			return (options.inclusive === true || options.inclusive === undefined)
                     ? {
-                        valid: value >= min && value <= max,
+                        valid: value >= minValue && value <= maxValue,
                         message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.between['default'], [min, max])
                     }
                     : {
-                        valid: value > min  && value <  max,
+                        valid: value > minValue  && value <  maxValue,
                         message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.between.notInclusive, [min, max])
                     };
+        },
+
+        _format: function(value) {
+            return (value + '').replace(',', '.');
         }
     };
 }(window.jQuery));

+ 10 - 4
src/js/validator/greaterThan.js

@@ -45,22 +45,28 @@
                 return true;
             }
             
-            value = value.replace(',', '.');
+            value = this._format(value);
             if (!$.isNumeric(value)) {
                 return false;
             }
 
-            var compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value);
+            var compareTo      = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value),
+                compareToValue = this._format(compareTo);
+
             value = parseFloat(value);
 			return (options.inclusive === true || options.inclusive === undefined)
                     ? {
-                        valid: value >= compareTo,
+                        valid: value >= compareToValue,
                         message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.greaterThan['default'], compareTo)
                     }
                     : {
-                        valid: value > compareTo,
+                        valid: value > compareToValue,
                         message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.greaterThan.notInclusive, compareTo)
                     };
+        },
+
+        _format: function(value) {
+            return (value + '').replace(',', '.');
         }
     };
 }(window.jQuery));

+ 10 - 4
src/js/validator/lessThan.js

@@ -45,22 +45,28 @@
                 return true;
             }
             
-			value = value.replace(',', '.');
+			value = this._format(value);
             if (!$.isNumeric(value)) {
                 return false;
             }
 
-            var compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value);
+            var compareTo      = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value),
+                compareToValue = this._format(compareTo);
+
             value = parseFloat(value);
             return (options.inclusive === true || options.inclusive === undefined)
                     ? {
-                        valid: value <= compareTo,
+                        valid: value <= compareToValue,
                         message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.lessThan['default'], compareTo)
                     }
                     : {
-                        valid: value < compareTo,
+                        valid: value < compareToValue,
                         message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.lessThan.notInclusive, compareTo)
                     };
+        },
+
+        _format: function(value) {
+            return (value + '').replace(',', '.');
         }
     };
 }(window.jQuery));

+ 66 - 32
test/spec.js

@@ -2214,10 +2214,8 @@ describe('between', function() {
     });
 
     it('compare to other field', function() {
-        this.$age.attr('data-bv-between-min', 'minAge')
-                 .attr('data-bv-between-max', 'maxAge');
-        this.bv.destroy();
-        this.bv = $('#betweenForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'between', 'min', 'minAge');
+        this.bv.updateOption('age', 'between', 'max', 'maxAge');
 
         this.$minAge.val(2);
         this.$maxAge.val(10);
@@ -2234,11 +2232,29 @@ describe('between', function() {
         expect(this.bv.getMessages('age', 'between')[0]).toEqual($.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.between['default'], [this.$minAge.val(), this.$maxAge.val()]));
     });
 
+    // #1048
+    it('compare to other field that value has comma', function() {
+        this.bv.updateOption('age', 'between', 'min', 'minAge');
+        this.bv.updateOption('age', 'between', 'max', 'maxAge');
+
+        this.$minAge.val('2,5');
+        this.$maxAge.val('10,5');
+        this.$age.val(5);
+        this.bv.validate();
+        expect(this.bv.isValid()).toBeTruthy();
+
+        this.bv.resetForm();
+        this.$minAge.val('20,5');
+        this.$maxAge.val('40,5');
+        this.$age.val(50);
+        this.bv.validate();
+        expect(this.bv.isValid()).toEqual(false);
+        expect(this.bv.getMessages('age', 'between')[0]).toEqual($.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.between['default'], [this.$minAge.val(), this.$maxAge.val()]));
+    });
+
     it('compare to return value of a function', function() {
-        this.$age.attr('data-bv-between-min', 'betweenCompareMin')
-                 .attr('data-bv-between-max', 'betweenCompareMax');
-        this.bv.destroy();
-        this.bv = $('#betweenForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'between', 'min', 'betweenCompareMin');
+        this.bv.updateOption('age', 'between', 'max', 'betweenCompareMax');
 
         this.$minAge.val(20);
         this.$maxAge.val(30);
@@ -2260,10 +2276,8 @@ describe('between', function() {
     });
 
     it('compare to return value of a namespace function', function() {
-        this.$age.attr('data-bv-between-min', 'TestSuite.between.compareToMin')
-                 .attr('data-bv-between-max', 'TestSuite.between.compareToMax');
-        this.bv.destroy();
-        this.bv = $('#betweenForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'between', 'min', 'TestSuite.between.compareToMin');
+        this.bv.updateOption('age', 'between', 'max', 'TestSuite.between.compareToMax');
 
         this.$minAge.val(20);
         this.$maxAge.val(30);
@@ -4257,7 +4271,7 @@ describe('greaterThan', function() {
         expect(this.bv.isValid()).toBeTruthy();
     });
 
-    it('value with coma separator', function() {
+    it('value with comma separator', function() {
         this.$age.val('10,4');
         this.bv.validate();
         expect(this.bv.isValid()).toEqual(false);
@@ -4269,9 +4283,7 @@ describe('greaterThan', function() {
     });
 
     it('compare to other field', function() {
-        this.$age.attr('data-bv-greaterthan-value', 'minAge');
-        this.bv.destroy();
-        this.bv = $('#greaterThanForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'greaterThan', 'value', 'minAge');
 
         this.$minAge.val(10);
         this.$age.val(20);
@@ -4286,10 +4298,24 @@ describe('greaterThan', function() {
         expect(this.bv.getMessages('age', 'greaterThan')[0]).toEqual($.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.greaterThan['default'], this.$minAge.val()));
     });
 
+    // #1048
+    it('compare to other field that value has comma', function() {
+        this.bv.updateOption('age', 'greaterThan', 'value', 'minAge');
+        this.$minAge.val('10,5');
+        this.$age.val(20);
+        this.bv.validate();
+        expect(this.bv.isValid()).toBeTruthy();
+
+        this.bv.resetForm();
+        this.$minAge.val('20,5');
+        this.$age.val(10);
+        this.bv.validate();
+        expect(this.bv.isValid()).toEqual(false);
+        expect(this.bv.getMessages('age', 'greaterThan')[0]).toEqual($.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.greaterThan['default'], this.$minAge.val()));
+    });
+
     it('compare to return value of a function', function() {
-        this.$age.attr('data-bv-greaterthan-value', 'greaterThanCompare');
-        this.bv.destroy();
-        this.bv = $('#greaterThanForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'greaterThan', 'value', 'greaterThanCompare');
 
         this.$minAge.val(20);
         this.$age.val(18);
@@ -4307,9 +4333,7 @@ describe('greaterThan', function() {
     });
 
     it('compare to return value of a namespace function', function() {
-        this.$age.attr('data-bv-greaterthan-value', 'TestSuite.greaterThan.compareTo');
-        this.bv.destroy();
-        this.bv = $('#greaterThanForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'greaterThan', 'value', 'TestSuite.greaterThan.compareTo');
 
         this.$minAge.val(20);
         this.$age.val(18);
@@ -5916,7 +5940,7 @@ describe('lessThan', function() {
         expect(this.bv.isValid()).toEqual(false);
     });
 
-    it('value with coma separator', function() {
+    it('value with comma separator', function() {
         this.$age.val('120,2234');
         this.bv.validate();
         expect(this.bv.isValid()).toEqual(false);
@@ -5939,9 +5963,7 @@ describe('lessThan', function() {
     });
 
     it('compare to other field', function() {
-        this.$age.attr('data-bv-lessthan-value', 'maxAge');
-        this.bv.destroy();
-        this.bv = $('#lessThanForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'lessThan', 'value', 'maxAge');
 
         this.$maxAge.val(40);
         this.$age.val(20);
@@ -5956,10 +5978,24 @@ describe('lessThan', function() {
         expect(this.bv.getMessages('age', 'lessThan')[0]).toEqual($.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.lessThan['default'], this.$maxAge.val()));
     });
 
+    // #1048
+    it('compare to other field that value has comma', function() {
+        this.bv.updateOption('age', 'lessThan', 'value', 'maxAge');
+        this.$maxAge.val('30,5');
+        this.$age.val(20);
+        this.bv.validate();
+        expect(this.bv.isValid()).toBeTruthy();
+
+        this.bv.resetForm();
+        this.$maxAge.val('20,5');
+        this.$age.val(30);
+        this.bv.validate();
+        expect(this.bv.isValid()).toEqual(false);
+        expect(this.bv.getMessages('age', 'lessThan')[0]).toEqual($.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.lessThan['default'], this.$maxAge.val()));
+    });
+
     it('compare to return value of a function', function() {
-        this.$age.attr('data-bv-lessthan-value', 'lessThanCompare');
-        this.bv.destroy();
-        this.bv = $('#lessThanForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'lessThan', 'value', 'lessThanCompare');
 
         this.$maxAge.val(50);
         this.$age.val(60);
@@ -5977,9 +6013,7 @@ describe('lessThan', function() {
     });
 
     it('compare to return value of a namespace function', function() {
-        this.$age.attr('data-bv-lessthan-value', 'TestSuite.lessThan.compareTo');
-        this.bv.destroy();
-        this.bv = $('#lessThanForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'lessThan', 'value', 'TestSuite.lessThan.compareTo');
 
         this.$maxAge.val(50);
         this.$age.val(60);

+ 26 - 12
test/spec/validator/between.js

@@ -79,10 +79,8 @@ describe('between', function() {
     });
 
     it('compare to other field', function() {
-        this.$age.attr('data-bv-between-min', 'minAge')
-                 .attr('data-bv-between-max', 'maxAge');
-        this.bv.destroy();
-        this.bv = $('#betweenForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'between', 'min', 'minAge');
+        this.bv.updateOption('age', 'between', 'max', 'maxAge');
 
         this.$minAge.val(2);
         this.$maxAge.val(10);
@@ -99,11 +97,29 @@ describe('between', function() {
         expect(this.bv.getMessages('age', 'between')[0]).toEqual($.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.between['default'], [this.$minAge.val(), this.$maxAge.val()]));
     });
 
+    // #1048
+    it('compare to other field that value has comma', function() {
+        this.bv.updateOption('age', 'between', 'min', 'minAge');
+        this.bv.updateOption('age', 'between', 'max', 'maxAge');
+
+        this.$minAge.val('2,5');
+        this.$maxAge.val('10,5');
+        this.$age.val(5);
+        this.bv.validate();
+        expect(this.bv.isValid()).toBeTruthy();
+
+        this.bv.resetForm();
+        this.$minAge.val('20,5');
+        this.$maxAge.val('40,5');
+        this.$age.val(50);
+        this.bv.validate();
+        expect(this.bv.isValid()).toEqual(false);
+        expect(this.bv.getMessages('age', 'between')[0]).toEqual($.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.between['default'], [this.$minAge.val(), this.$maxAge.val()]));
+    });
+
     it('compare to return value of a function', function() {
-        this.$age.attr('data-bv-between-min', 'betweenCompareMin')
-                 .attr('data-bv-between-max', 'betweenCompareMax');
-        this.bv.destroy();
-        this.bv = $('#betweenForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'between', 'min', 'betweenCompareMin');
+        this.bv.updateOption('age', 'between', 'max', 'betweenCompareMax');
 
         this.$minAge.val(20);
         this.$maxAge.val(30);
@@ -125,10 +141,8 @@ describe('between', function() {
     });
 
     it('compare to return value of a namespace function', function() {
-        this.$age.attr('data-bv-between-min', 'TestSuite.between.compareToMin')
-                 .attr('data-bv-between-max', 'TestSuite.between.compareToMax');
-        this.bv.destroy();
-        this.bv = $('#betweenForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'between', 'min', 'TestSuite.between.compareToMin');
+        this.bv.updateOption('age', 'between', 'max', 'TestSuite.between.compareToMax');
 
         this.$minAge.val(20);
         this.$maxAge.val(30);

+ 20 - 10
test/spec/validator/greaterThan.js

@@ -56,7 +56,7 @@ describe('greaterThan', function() {
         expect(this.bv.isValid()).toBeTruthy();
     });
 
-    it('value with coma separator', function() {
+    it('value with comma separator', function() {
         this.$age.val('10,4');
         this.bv.validate();
         expect(this.bv.isValid()).toEqual(false);
@@ -68,9 +68,7 @@ describe('greaterThan', function() {
     });
 
     it('compare to other field', function() {
-        this.$age.attr('data-bv-greaterthan-value', 'minAge');
-        this.bv.destroy();
-        this.bv = $('#greaterThanForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'greaterThan', 'value', 'minAge');
 
         this.$minAge.val(10);
         this.$age.val(20);
@@ -85,10 +83,24 @@ describe('greaterThan', function() {
         expect(this.bv.getMessages('age', 'greaterThan')[0]).toEqual($.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.greaterThan['default'], this.$minAge.val()));
     });
 
+    // #1048
+    it('compare to other field that value has comma', function() {
+        this.bv.updateOption('age', 'greaterThan', 'value', 'minAge');
+        this.$minAge.val('10,5');
+        this.$age.val(20);
+        this.bv.validate();
+        expect(this.bv.isValid()).toBeTruthy();
+
+        this.bv.resetForm();
+        this.$minAge.val('20,5');
+        this.$age.val(10);
+        this.bv.validate();
+        expect(this.bv.isValid()).toEqual(false);
+        expect(this.bv.getMessages('age', 'greaterThan')[0]).toEqual($.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.greaterThan['default'], this.$minAge.val()));
+    });
+
     it('compare to return value of a function', function() {
-        this.$age.attr('data-bv-greaterthan-value', 'greaterThanCompare');
-        this.bv.destroy();
-        this.bv = $('#greaterThanForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'greaterThan', 'value', 'greaterThanCompare');
 
         this.$minAge.val(20);
         this.$age.val(18);
@@ -106,9 +118,7 @@ describe('greaterThan', function() {
     });
 
     it('compare to return value of a namespace function', function() {
-        this.$age.attr('data-bv-greaterthan-value', 'TestSuite.greaterThan.compareTo');
-        this.bv.destroy();
-        this.bv = $('#greaterThanForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'greaterThan', 'value', 'TestSuite.greaterThan.compareTo');
 
         this.$minAge.val(20);
         this.$age.val(18);

+ 20 - 10
test/spec/validator/lessThan.js

@@ -45,7 +45,7 @@ describe('lessThan', function() {
         expect(this.bv.isValid()).toEqual(false);
     });
 
-    it('value with coma separator', function() {
+    it('value with comma separator', function() {
         this.$age.val('120,2234');
         this.bv.validate();
         expect(this.bv.isValid()).toEqual(false);
@@ -68,9 +68,7 @@ describe('lessThan', function() {
     });
 
     it('compare to other field', function() {
-        this.$age.attr('data-bv-lessthan-value', 'maxAge');
-        this.bv.destroy();
-        this.bv = $('#lessThanForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'lessThan', 'value', 'maxAge');
 
         this.$maxAge.val(40);
         this.$age.val(20);
@@ -85,10 +83,24 @@ describe('lessThan', function() {
         expect(this.bv.getMessages('age', 'lessThan')[0]).toEqual($.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.lessThan['default'], this.$maxAge.val()));
     });
 
+    // #1048
+    it('compare to other field that value has comma', function() {
+        this.bv.updateOption('age', 'lessThan', 'value', 'maxAge');
+        this.$maxAge.val('30,5');
+        this.$age.val(20);
+        this.bv.validate();
+        expect(this.bv.isValid()).toBeTruthy();
+
+        this.bv.resetForm();
+        this.$maxAge.val('20,5');
+        this.$age.val(30);
+        this.bv.validate();
+        expect(this.bv.isValid()).toEqual(false);
+        expect(this.bv.getMessages('age', 'lessThan')[0]).toEqual($.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.lessThan['default'], this.$maxAge.val()));
+    });
+
     it('compare to return value of a function', function() {
-        this.$age.attr('data-bv-lessthan-value', 'lessThanCompare');
-        this.bv.destroy();
-        this.bv = $('#lessThanForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'lessThan', 'value', 'lessThanCompare');
 
         this.$maxAge.val(50);
         this.$age.val(60);
@@ -106,9 +118,7 @@ describe('lessThan', function() {
     });
 
     it('compare to return value of a namespace function', function() {
-        this.$age.attr('data-bv-lessthan-value', 'TestSuite.lessThan.compareTo');
-        this.bv.destroy();
-        this.bv = $('#lessThanForm').bootstrapValidator().data('bootstrapValidator');
+        this.bv.updateOption('age', 'lessThan', 'value', 'TestSuite.lessThan.compareTo');
 
         this.$maxAge.val(50);
         this.$age.val(60);