var mediaType = "\\w+\\/[-+.\\w]+(?:;[\\w=]+)*";
var urlchar = "[A-Za-z0-9-_.!~\\*'();\\/?:@&=+$,%]*";
var dataurl = "data:(?:"+mediaType+")?(?:;base64)?,"+urlchar;
regex = "(?:"+regex+")|(?:^"+dataurl+"$)";
}
var PATTERN = new RegExp(regex, 'i');
if (!PATTERN.exec(value)) {
return message;
}
},
type: v.extend(function(value, originalOptions, attribute, attributes, globalOptions) {
if (v.isString(originalOptions)) {
originalOptions = {type: originalOptions};
}
if (!v.isDefined(value)) {
return;
}
var options = v.extend({}, this.options, originalOptions);
var type = options.type;
if (!v.isDefined(type)) {
throw new Error("No type was specified");
}
var check;
if (v.isFunction(type)) {
check = type;
} else {
check = this.types[type];
}
if (!v.isFunction(check)) {
throw new Error("validate.validators.type.types." + type + " must be a function.");
}
if (!check(value, options, attribute, attributes, globalOptions)) {
var message = originalOptions.message ||
this.messages[type] ||
this.message ||
options.message ||
(v.isFunction(type) ? "must be of the correct type" : "must be of type %{type}");
if (v.isFunction(message)) {
message = message(value, originalOptions, attribute, attributes, globalOptions);
}
return v.format(message, {attribute: v.prettify(attribute), type: type});
}
}, {
types: {
object: function(value) {
return v.isObject(value) && !v.isArray(value);
},
array: v.isArray,
integer: v.isInteger,
number: v.isNumber,
string: v.isString,
date: v.isDate,
boolean: v.isBoolean
},
messages: {}
})
};
validate.formatters = {
detailed: function(errors) {return errors;},
flat: v.flattenErrorsToArray,
grouped: function(errors) {
var attr;
errors = v.groupErrorsByAttribute(errors);
for (attr in errors) {
errors[attr] = v.flattenErrorsToArray(errors[attr]);
}
return errors;
},
constraint: function(errors) {
var attr;
errors = v.groupErrorsByAttribute(errors);
for (attr in errors) {
errors[attr] = errors[attr].map(function(result) {
return result.validator;
}).sort();
}
return errors;
}
};
validate.exposeModule(validate, this, exports, module, define);
}).call(this,
typeof exports !== 'undefined' ? exports : null,
typeof module !== 'undefined' ? module : null,
typeof define !== 'undefined' ? define : null);