|
|
@@ -22,20 +22,23 @@
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
- return isValid || { valid: false, message: message };
|
|
|
+ return isValid || {
|
|
|
+ valid: false,
|
|
|
+ message: formatedMessage
|
|
|
+ };
|
|
|
},
|
|
|
|
|
|
_hex: function(value) {
|