ソースを参照

Refactor test suite for color validator.
Create Test cases for validation messages for color Test suite

Emil Rømer Christensen 11 年 前
コミット
0fd2fa3b41

+ 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-09-18 10:04:30 PM
+ * @version     v0.5.2-dev, built on 2014-09-18 10:04:40 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 14 - 7
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-09-18 10:04:30 PM
+ * @version     v0.5.2-dev, built on 2014-09-18 10:04:40 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -2205,20 +2205,27 @@ if (typeof jQuery === 'undefined') {
                 return true;
             }
 
-            var method;
+            var method, type;
             var defaultTypes = ['hex', 'rgb', 'rgba', 'hsl', 'hsla', 'keyword'];
             var useCustomTypes = (options.hasOwnProperty('type') && options.type instanceof Array);
             var types = useCustomTypes ? options.type : defaultTypes;
             var isValid = false;
+            var formatedMessage = $.fn.bootstrapValidator.helpers.format(
+                                        options.message || (useCustomTypes ? $.fn.bootstrapValidator.i18n.color.type : $.fn.bootstrapValidator.i18n.color.default),
+                                        types.join(", ")
+            );
 
-            for (var i = 0; i<types.length; i++) {
-                var type = types[i];
-                message = useCustomTypes ? $.fn.bootstrapValidator.i18n.color.type : $.fn.bootstrapValidator.i18n.color.default;
-                method = ['_', type.toLowerCase()].join('');
+            for (var i = 0; i < types.length; i++) {
+                type = types[i];
+                method = '_' + type.toLowerCase();
                 isValid = isValid || this[method](value);
+                if (isValid) return true;
             }
 
-            return isValid || { valid: false, message: message };
+            return {
+                valid: false,
+                message: formatedMessage
+            };
         },
 
         _hex: function(value) {

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


ファイルの差分が大きいため隠しています
+ 437 - 417
test/spec.js


ファイルの差分が大きいため隠しています
+ 437 - 417
test/spec/validator/color.js