validate.js
Advanced tools
Comparing version 0.9.0 to 0.10.0
{ | ||
"name": "validate", | ||
"description": "Declarative validations for JavaScript", | ||
"main": "validate.js", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"moduleType": [ | ||
"amd", | ||
"globals", | ||
"node" | ||
], | ||
"keywords": [ | ||
"validation", | ||
"javascript", | ||
"library" | ||
], | ||
"authors": [ | ||
"Nicklas Ansman" | ||
], | ||
"license": "MIT", | ||
"ignore": [ | ||
@@ -9,14 +24,11 @@ "**/.*", | ||
"docs", | ||
"spec", | ||
"*.md", | ||
"specs", | ||
"CONTRIBUTING.md", | ||
"*.html", | ||
"Gruntfile.js", | ||
"package.json", | ||
"bower.json" | ||
], | ||
"keywords": [ | ||
"validation", | ||
"javascript", | ||
"library" | ||
"component.json", | ||
"favicon.png", | ||
"RELEASING.txt" | ||
] | ||
} |
@@ -8,5 +8,5 @@ { | ||
"scripts" : ["validate.js"], | ||
"version" : "0.9.0", | ||
"version" : "0.10.0", | ||
"license" : "MIT" | ||
} | ||
The MIT License (MIT) | ||
Copyright (c) 2013-2015 Nicklas Ansman, 2013 Wrapp | ||
Copyright (c) 2013-2016 Nicklas Ansman, 2013 Wrapp | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "validate.js", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"author": "Nicklas Ansman <nicklas@ansman.se>", | ||
@@ -28,13 +28,10 @@ "description": "Declarative validations for JavaScript", | ||
"grunt-contrib-watch": "0.6.1", | ||
"grunt-contrib-jshint": "0.11.1", | ||
"grunt-contrib-uglify": "0.9.1", | ||
"grunt-contrib-jasmine": "0.8.2", | ||
"grunt-docco": "0.3.3", | ||
"grunt-template-jasmine-istanbul": "0.3.3", | ||
"coveralls": "2.11.2" | ||
"grunt-contrib-jshint": "0.11.3", | ||
"grunt-contrib-uglify": "0.9.2", | ||
"grunt-contrib-jasmine": "0.9.2", | ||
"grunt-docco": "0.4.0", | ||
"grunt-template-jasmine-istanbul": "0.3.4", | ||
"coveralls": "2.11.4" | ||
}, | ||
"licenses": [{ | ||
"type": "MIT", | ||
"url": "https://github.com/ansman/validate.js/tree/master/LICENSE.txt" | ||
}] | ||
"license": "MIT" | ||
} |
@@ -65,2 +65,18 @@ describe("validate", function() { | ||
describe('isBoolean', function() { | ||
it("returns true for booleans", function() { | ||
expect(validate.isBoolean(true)).toBe(true); | ||
expect(validate.isBoolean(false)).toBe(true); | ||
}); | ||
it("returns false for non booleans ", function() { | ||
expect(validate.isBoolean(null)).toBe(false); | ||
expect(validate.isBoolean({})).toBe(false); | ||
expect(validate.isBoolean({foo: "bar"})).toBe(false); | ||
expect(validate.isBoolean([])).toBe(false); | ||
expect(validate.isBoolean("")).toBe(false); | ||
expect(validate.isBoolean(function() {})).toBe(false); | ||
}); | ||
}); | ||
describe('isObject', function() { | ||
@@ -229,2 +245,18 @@ it("returns true for objects", function() { | ||
describe('isHash', function() { | ||
it("returns true for hashes", function() { | ||
expect(validate.isHash({})).toBe(true); | ||
expect(validate.isHash({foo: "bar"})).toBe(true); | ||
}); | ||
it("returns false for non hashes", function() { | ||
expect(validate.isHash([])).toBe(false); | ||
expect(validate.isHash(function() {})).toBe(false); | ||
expect(validate.isHash(null)).toBe(false); | ||
expect(validate.isHash(1)).toBe(false); | ||
expect(validate.isHash("")).toBe(false); | ||
expect(validate.isHash(false)).toBe(false); | ||
}); | ||
}); | ||
describe('contains', function() { | ||
@@ -1090,2 +1122,28 @@ var contains = validate.contains; | ||
}); | ||
describe("unique", function() { | ||
it("handles empty and single value arrays", function() { | ||
expect(validate.unique(null)).toEqual(null); | ||
expect(validate.unique([])).toEqual([]); | ||
expect(validate.unique([1])).toEqual([1]); | ||
expect(validate.unique(["foo"])).toEqual(["foo"]); | ||
expect(validate.unique("foo")).toEqual("foo"); | ||
}); | ||
it("filters non unique values", function() { | ||
expect(validate.unique(["foo", "bar", "bar", "foo", "baz"])) | ||
.toEqual(["foo", "bar", "baz"]); | ||
expect(validate.unique(["foo", "foo", "foo"])) | ||
.toEqual(["foo"]); | ||
expect(validate.unique([1, 2, 3, 3, 2, 1])) | ||
.toEqual([1, 2, 3]); | ||
}); | ||
it("returns a copy", function() { | ||
var a = ["foo"]; | ||
expect(validate.unique(a)).not.toBe(a); | ||
}); | ||
}); | ||
}); |
@@ -11,3 +11,7 @@ describe('validators.datetime', function() { | ||
validate.validators.datetime.format = function(value, options) { | ||
return moment.utc(value).format("YYYY-MM-DD HH:mm:ss"); | ||
var format = "YYYY-MM-DD"; | ||
if (!options.dateOnly) { | ||
format += " HH:mm:ss"; | ||
} | ||
return moment.utc(value).format(format); | ||
}; | ||
@@ -80,2 +84,33 @@ }); | ||
it("allows tooLate, tooEarly and notValid messages", function() { | ||
var options = { | ||
tooLate: "%{value} is later than %{date}", | ||
tooEarly: "%{value} is earlier than %{date}", | ||
notValid: "%{value} is not valid", | ||
message: "fail", | ||
earliest: "2015-01-01", | ||
latest: "2015-12-31", | ||
dateOnly: true | ||
}; | ||
expect(datetime("foobar", options)).toEqual("foobar is not valid"); | ||
expect(datetime("2014-01-01", options)) | ||
.toEqual(["2014-01-01 is earlier than 2015-01-01"]); | ||
expect(datetime("2016-01-01", options)) | ||
.toEqual(["2016-01-01 is later than 2015-12-31"]); | ||
}); | ||
it("message overrides global messages", function() { | ||
var options = { | ||
message: "some message", | ||
earliest: "2016-01-01", | ||
latest: "2015-12-30", | ||
dateOnly: true | ||
}; | ||
validate.validators.datetime.notValid = "notValid"; | ||
validate.validators.datetime.tooEarly = "tooEarly"; | ||
validate.validators.datetime.tooLate = "tooLate"; | ||
expect(datetime("foobar", options)).toEqual("some message"); | ||
expect(datetime("2015-12-31", options)).toEqual(["some message"]); | ||
}); | ||
describe("earliest", function() { | ||
@@ -123,3 +158,3 @@ it("doesn't allow earlier dates", function() { | ||
options.message = "overridden"; | ||
expect(datetime(value, options)).toEqual("overridden"); | ||
expect(datetime(value, options)).toEqual(["overridden"]); | ||
}); | ||
@@ -169,3 +204,3 @@ }); | ||
options.message = "overridden"; | ||
expect(datetime(value, options)).toEqual("overridden"); | ||
expect(datetime(value, options)).toEqual(["overridden"]); | ||
}); | ||
@@ -193,3 +228,3 @@ }); | ||
, value = "2013-10-25 00:00:00"; | ||
expect(datetime(value, options)).toEqual('foobar'); | ||
expect(datetime(value, options)).toEqual(['foobar']); | ||
}); | ||
@@ -202,4 +237,4 @@ | ||
, value = "2013-10-25 00:00:00"; | ||
expect(datetime(value, options)).toEqual('foobar'); | ||
expect(datetime(value, {})).toEqual('barfoo'); | ||
expect(datetime(value, options)).toEqual(['foobar']); | ||
expect(datetime(value, {})).toEqual(['barfoo']); | ||
expect(validate.validators.datetime.options) | ||
@@ -218,3 +253,3 @@ .toEqual({message: "barfoo", earliest: "2013-10-26 00:00:00"}); | ||
, value = "2013-10-25 00:00:00"; | ||
expect(datetime(value, options)).toBe(message); | ||
expect(datetime(value, options)).toEqual([message]); | ||
}); | ||
@@ -221,0 +256,0 @@ }); |
@@ -16,2 +16,3 @@ describe("validators.numericality", function() { | ||
delete n.notLessThanOrEqualTo; | ||
delete n.notDivisibleBy; | ||
delete n.options; | ||
@@ -197,2 +198,26 @@ }); | ||
describe("divisibleBy", function() { | ||
it("allows numbers divisible by the value", function() { | ||
expect(numericality(0, {divisibleBy: 2})).not.toBeDefined(); | ||
expect(numericality(5, {divisibleBy: 5})).not.toBeDefined(); | ||
expect(numericality(16, {divisibleBy: 8})).not.toBeDefined(); | ||
}); | ||
it("doesn't allow numbers that are not divisible by the given number", function() { | ||
var expected = ["must be divisible by 100"]; | ||
expect(numericality(121, {divisibleBy: 100})).toEqual(expected); | ||
}); | ||
it("allows for a default message", function() { | ||
var expected = "default message"; | ||
validate.validators.numericality.notDivisibleBy = expected; | ||
expect(numericality(161, {divisibleBy: 200})).toEqual([expected]); | ||
}); | ||
it("allows for a custom message", function() { | ||
var expected = "custom message"; | ||
expect(numericality(133, {divisibleBy: 4, notDivisibleBy: expected})).toEqual([expected]); | ||
}); | ||
}); | ||
describe("odd", function() { | ||
@@ -256,2 +281,3 @@ it("allows odd numbers", function() { | ||
lessThanOrEqualTo: 5, | ||
divisibleBy: 10, | ||
equalTo: 20, | ||
@@ -261,3 +287,3 @@ odd: true, | ||
}; | ||
expect(numericality(7.2, options)).toHaveLength(7); | ||
expect(numericality(7.2, options)).toHaveLength(8); | ||
}); | ||
@@ -271,2 +297,3 @@ | ||
lessThanOrEqualTo: 5, | ||
divisibleBy: 10, | ||
equalTo: 20, | ||
@@ -301,2 +328,30 @@ odd: true, | ||
}); | ||
describe("strict", function() { | ||
it("disallows prefixed zeros", function() { | ||
expect(numericality("01.0", {strict: true})) | ||
.toEqual("must be a valid number"); | ||
expect(numericality("0001.0000000", {strict: true})) | ||
.toEqual("must be a valid number"); | ||
expect(numericality("020", {strict: true})) | ||
.toEqual("must be a valid number"); | ||
expect(numericality("1.00", {strict: true, onlyInteger: true})) | ||
.toEqual("must be a valid number"); | ||
expect(numericality("1.", {strict: true})) | ||
.toEqual("must be a valid number"); | ||
expect(numericality("1.", {strict: true, onlyInteger: true})) | ||
.toEqual("must be a valid number"); | ||
expect(numericality(".0", {strict: true})) | ||
.toEqual("must be a valid number"); | ||
expect(numericality(".1", {strict: true})) | ||
.toEqual("must be a valid number"); | ||
expect(numericality("1.00", {strict: true})).not.toBeDefined(); | ||
expect(numericality("1.0", {strict: true})).not.toBeDefined(); | ||
expect(numericality(10, {strict: true})).not.toBeDefined(); | ||
expect(numericality("10", {strict: true})).not.toBeDefined(); | ||
expect(numericality("0.1", {strict: true})).not.toBeDefined(); | ||
expect(numericality("0", {strict: true})).not.toBeDefined(); | ||
}); | ||
}); | ||
}); |
@@ -111,2 +111,4 @@ describe("validators.url", function() { | ||
expect(url("http://localhost:4711/foo", {allowLocal: true})).not.toBeDefined(); | ||
// Issue #95 | ||
expect(url("http://servername01:8153/go/cctray.xml", {allowLocal: true})).not.toBeDefined(); | ||
expect(url("http://nicklas:password@localhost:4711/foo", {allowLocal: true})).not.toBeDefined(); | ||
@@ -113,0 +115,0 @@ }); |
104
validate.js
/*! | ||
* validate.js 0.9.0 | ||
* validate.js 0.10.0 | ||
* | ||
* (c) 2013-2015 Nicklas Ansman, 2013 Wrapp | ||
* (c) 2013-2016 Nicklas Ansman, 2013 Wrapp | ||
* Validate.js may be freely distributed under the MIT license. | ||
@@ -59,3 +59,3 @@ * For all details and documentation: | ||
major: 0, | ||
minor: 9, | ||
minor: 10, | ||
patch: 0, | ||
@@ -282,2 +282,7 @@ metadata: null, | ||
// Checks if the value is a boolean | ||
isBoolean: function(value) { | ||
return typeof value === 'boolean'; | ||
}, | ||
// Uses the `Object` function to check if the given argument is an object. | ||
@@ -313,3 +318,3 @@ isObject: function(obj) { | ||
if (!v.isFunction(o.querySelectorAll) || !v.isFunction(o.querySelector)) { | ||
if (!o.querySelectorAll || !o.querySelector) { | ||
return false; | ||
@@ -447,2 +452,8 @@ } | ||
// Checks if the object is a hash, which is equivalent to an object that | ||
// is neither an array nor a function. | ||
isHash: function(value) { | ||
return v.isObject(value) && !v.isArray(value) && !v.isFunction(value); | ||
}, | ||
contains: function(obj, value) { | ||
@@ -458,2 +469,11 @@ if (!v.isDefined(obj)) { | ||
unique: function(array) { | ||
if (!v.isArray(array)) { | ||
return array; | ||
} | ||
return array.filter(function(el, index, array) { | ||
return array.indexOf(el) == index; | ||
}); | ||
}, | ||
forEachKeyInKeypath: function(object, keypath, callback) { | ||
@@ -823,5 +843,19 @@ if (!v.isString(keypath)) { | ||
lessThan: function(v, c) { return v < c; }, | ||
lessThanOrEqualTo: function(v, c) { return v <= c; } | ||
lessThanOrEqualTo: function(v, c) { return v <= c; }, | ||
divisibleBy: function(v, c) { return v % c === 0; } | ||
}; | ||
// Strict will check that it is a valid looking number | ||
if (v.isString(value) && options.strict) { | ||
var pattern = "^(0|[1-9]\\d*)"; | ||
if (!options.onlyInteger) { | ||
pattern += "(\\.\\d+)?"; | ||
} | ||
pattern += "$"; | ||
if (!(new RegExp(pattern).test(value))) { | ||
return options.message || options.notValid || this.notValid || "must be a valid number"; | ||
} | ||
} | ||
// Coerce the value to a number unless we're being strict. | ||
@@ -892,8 +926,18 @@ if (options.noStrings !== true && v.isString(value)) { | ||
if (isNaN(value) || options.dateOnly && value % 86400000 !== 0) { | ||
return options.message || this.notValid || "must be a valid date"; | ||
err = options.notValid || | ||
options.message || | ||
this.notValid || | ||
"must be a valid date"; | ||
return v.format(err, {value: arguments[0]}); | ||
} | ||
if (!isNaN(earliest) && value < earliest) { | ||
err = this.tooEarly || "must be no earlier than %{date}"; | ||
err = v.format(err, {date: this.format(earliest, options)}); | ||
err = options.tooEarly || | ||
options.message || | ||
this.tooEarly || | ||
"must be no earlier than %{date}"; | ||
err = v.format(err, { | ||
value: this.format(value, options), | ||
date: this.format(earliest, options) | ||
}); | ||
errors.push(err); | ||
@@ -903,4 +947,10 @@ } | ||
if (!isNaN(latest) && value > latest) { | ||
err = this.tooLate || "must be no later than %{date}"; | ||
err = v.format(err, {date: this.format(latest, options)}); | ||
err = options.tooLate || | ||
options.message || | ||
this.tooLate || | ||
"must be no later than %{date}"; | ||
err = v.format(err, { | ||
date: this.format(latest, options), | ||
value: this.format(value, options) | ||
}); | ||
errors.push(err); | ||
@@ -910,3 +960,3 @@ } | ||
if (errors.length) { | ||
return options.message || errors; | ||
return v.unique(errors); | ||
} | ||
@@ -1050,23 +1100,25 @@ }, { | ||
var hostname = | ||
"(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)" + | ||
"(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*" + | ||
"(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))"; | ||
var tld = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))"; | ||
// This ia a special case for the localhost hostname | ||
if (allowLocal) { | ||
hostname = "(?:localhost|" + hostname + ")"; | ||
tld += "?"; | ||
} else { | ||
// private & local addresses | ||
regex += | ||
"(?!10(?:\\.\\d{1,3}){3})" + | ||
"(?!127(?:\\.\\d{1,3}){3})" + | ||
"(?!169\\.254(?:\\.\\d{1,3}){2})" + | ||
"(?!192\\.168(?:\\.\\d{1,3}){2})" + | ||
"(?!172" + | ||
"\\.(?:1[6-9]|2\\d|3[0-1])" + | ||
"(?:\\.\\d{1,3})" + | ||
"{2})"; | ||
// private & local addresses | ||
regex += | ||
"(?!10(?:\\.\\d{1,3}){3})" + | ||
"(?!127(?:\\.\\d{1,3}){3})" + | ||
"(?!169\\.254(?:\\.\\d{1,3}){2})" + | ||
"(?!192\\.168(?:\\.\\d{1,3}){2})" + | ||
"(?!172" + | ||
"\\.(?:1[6-9]|2\\d|3[0-1])" + | ||
"(?:\\.\\d{1,3})" + | ||
"{2})"; | ||
} | ||
var hostname = | ||
"(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)" + | ||
"(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*" + | ||
tld + ")"; | ||
// reserved addresses | ||
@@ -1073,0 +1125,0 @@ regex += |
/*! | ||
* validate.js 0.9.0 | ||
* validate.js 0.10.0 | ||
* http://validatejs.org/ | ||
@@ -8,3 +8,3 @@ * (c) 2013-2015 Nicklas Ansman, 2013 Wrapp | ||
(function(a,b,c){"use strict";var d=function(a,b,c){c=e.extend({},e.options,c);var f,g,h=e.runValidations(a,b,c);for(f in h)for(g in h[f])if(e.isPromise(h[f][g]))throw new Error("Use validate.async if you want support for promises");return d.processValidationResults(h,c)},e=d;e.extend=function(a){return[].slice.call(arguments,1).forEach(function(b){for(var c in b)a[c]=b[c]}),a},e.extend(d,{version:{major:0,minor:9,patch:0,metadata:null,toString:function(){var a=e.format("%{major}.%{minor}.%{patch}",e.version);return e.isEmpty(e.version.metadata)||(a+="+"+e.version.metadata),a}},Promise:"undefined"!=typeof Promise?Promise:null,EMPTY_STRING_REGEXP:/^\s*$/,runValidations:function(a,b,c){var d,f,g,h,i,j,k,l=[];(e.isDomElement(a)||e.isJqueryElement(a))&&(a=e.collectFormValues(a));for(d in b){g=e.getDeepObjectValue(a,d),h=e.result(b[d],g,a,d,c,b);for(f in h){if(i=e.validators[f],!i)throw k=e.format("Unknown validator %{name}",{name:f}),new Error(k);j=h[f],j=e.result(j,g,a,d,c,b),j&&l.push({attribute:d,value:g,validator:f,globalOptions:c,attributes:a,options:j,error:i.call(i,g,j,d,a,c)})}}return l},processValidationResults:function(a,b){var c;switch(a=e.pruneEmptyErrors(a,b),a=e.expandMultipleErrors(a,b),a=e.convertErrorMessages(a,b),b.format||"grouped"){case"detailed":break;case"flat":a=e.flattenErrorsToArray(a);break;case"grouped":a=e.groupErrorsByAttribute(a);for(c in a)a[c]=e.flattenErrorsToArray(a[c]);break;default:throw new Error(e.format("Unknown format %{format}",b))}return e.isEmpty(a)?void 0:a},async:function(a,b,c){c=e.extend({},e.async.options,c);var d=c.wrapErrors||function(a){return a};c.cleanAttributes!==!1&&(a=e.cleanAttributes(a,b));var f=e.runValidations(a,b,c);return new e.Promise(function(g,h){e.waitForResults(f).then(function(){var i=e.processValidationResults(f,c);i?h(new d(i,c,a,b)):g(a)},function(a){h(a)})})},single:function(a,b,c){return c=e.extend({},e.single.options,c,{format:"flat",fullMessages:!1}),e({single:a},{single:b},c)},waitForResults:function(a){return a.reduce(function(a,b){return e.isPromise(b.error)?a.then(function(){return b.error.then(function(a){b.error=a||null},function(a){if(a instanceof Error)throw a;e.error("Rejecting promises with the result is deprecated. Please use the resolve callback instead."),b.error=a})}):a},new e.Promise(function(a){a()}))},result:function(a){var b=[].slice.call(arguments,1);return"function"==typeof a&&(a=a.apply(null,b)),a},isNumber:function(a){return"number"==typeof a&&!isNaN(a)},isFunction:function(a){return"function"==typeof a},isInteger:function(a){return e.isNumber(a)&&a%1===0},isObject:function(a){return a===Object(a)},isDate:function(a){return a instanceof Date},isDefined:function(a){return null!==a&&void 0!==a},isPromise:function(a){return!!a&&e.isFunction(a.then)},isJqueryElement:function(a){return a&&e.isString(a.jquery)},isDomElement:function(a){return a&&e.isFunction(a.querySelectorAll)&&e.isFunction(a.querySelector)?e.isObject(document)&&a===document?!0:"object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName:!1},isEmpty:function(a){var b;if(!e.isDefined(a))return!0;if(e.isFunction(a))return!1;if(e.isString(a))return e.EMPTY_STRING_REGEXP.test(a);if(e.isArray(a))return 0===a.length;if(e.isDate(a))return!1;if(e.isObject(a)){for(b in a)return!1;return!0}return!1},format:e.extend(function(a,b){return e.isString(a)?a.replace(e.format.FORMAT_REGEXP,function(a,c,d){return"%"===c?"%{"+d+"}":String(b[d])}):a},{FORMAT_REGEXP:/(%?)%\{([^\}]+)\}/g}),prettify:function(a){return e.isNumber(a)?100*a%1===0?""+a:parseFloat(Math.round(100*a)/100).toFixed(2):e.isArray(a)?a.map(function(a){return e.prettify(a)}).join(", "):e.isObject(a)?a.toString():(a=""+a,a.replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(a,b,c){return""+b+" "+c.toLowerCase()}).toLowerCase())},stringifyValue:function(a){return e.prettify(a)},isString:function(a){return"string"==typeof a},isArray:function(a){return"[object Array]"==={}.toString.call(a)},contains:function(a,b){return e.isDefined(a)?e.isArray(a)?-1!==a.indexOf(b):b in a:!1},forEachKeyInKeypath:function(a,b,c){if(!e.isString(b))return void 0;var d,f="",g=!1;for(d=0;d<b.length;++d)switch(b[d]){case".":g?(g=!1,f+="."):(a=c(a,f,!1),f="");break;case"\\":g?(g=!1,f+="\\"):g=!0;break;default:g=!1,f+=b[d]}return c(a,f,!0)},getDeepObjectValue:function(a,b){return e.isObject(a)?e.forEachKeyInKeypath(a,b,function(a,b){return e.isObject(a)?a[b]:void 0}):void 0},collectFormValues:function(a,b){var c,d,f,g,h={};if(e.isJqueryElement(a)&&(a=a[0]),!a)return h;for(b=b||{},f=a.querySelectorAll("input[name], textarea[name]"),c=0;c<f.length;++c)d=f.item(c),e.isDefined(d.getAttribute("data-ignored"))||(g=e.sanitizeFormValue(d.value,b),"number"===d.type?g=g?+g:null:"checkbox"===d.type?d.attributes.value?d.checked||(g=h[d.name]||null):g=d.checked:"radio"===d.type&&(d.checked||(g=h[d.name]||null)),h[d.name]=g);for(f=a.querySelectorAll("select[name]"),c=0;c<f.length;++c)d=f.item(c),g=e.sanitizeFormValue(d.options[d.selectedIndex].value,b),h[d.name]=g;return h},sanitizeFormValue:function(a,b){return b.trim&&e.isString(a)&&(a=a.trim()),b.nullify!==!1&&""===a?null:a},capitalize:function(a){return e.isString(a)?a[0].toUpperCase()+a.slice(1):a},pruneEmptyErrors:function(a){return a.filter(function(a){return!e.isEmpty(a.error)})},expandMultipleErrors:function(a){var b=[];return a.forEach(function(a){e.isArray(a.error)?a.error.forEach(function(c){b.push(e.extend({},a,{error:c}))}):b.push(a)}),b},convertErrorMessages:function(a,b){b=b||{};var c=[];return a.forEach(function(a){var d=e.result(a.error,a.value,a.attribute,a.options,a.attributes,a.globalOptions);return e.isString(d)?("^"===d[0]?d=d.slice(1):b.fullMessages!==!1&&(d=e.capitalize(e.prettify(a.attribute))+" "+d),d=d.replace(/\\\^/g,"^"),d=e.format(d,{value:e.stringifyValue(a.value)}),void c.push(e.extend({},a,{error:d}))):void c.push(a)}),c},groupErrorsByAttribute:function(a){var b={};return a.forEach(function(a){var c=b[a.attribute];c?c.push(a):b[a.attribute]=[a]}),b},flattenErrorsToArray:function(a){return a.map(function(a){return a.error})},cleanAttributes:function(a,b){function c(a,b,c){return e.isObject(a[b])?a[b]:a[b]=c?!0:{}}function d(a){var b,d={};for(b in a)a[b]&&e.forEachKeyInKeypath(d,b,c);return d}function f(a,b){if(!e.isObject(a))return a;var c,d,g=e.extend({},a);for(d in a)c=b[d],e.isObject(c)?g[d]=f(g[d],c):c||delete g[d];return g}return e.isObject(b)&&e.isObject(a)?(b=d(b),f(a,b)):{}},exposeModule:function(a,b,c,d,e){c?(d&&d.exports&&(c=d.exports=a),c.validate=a):(b.validate=a,a.isFunction(e)&&e.amd&&e([],function(){return a}))},warn:function(a){"undefined"!=typeof console&&console.warn&&console.warn("[validate.js] "+a)},error:function(a){"undefined"!=typeof console&&console.error&&console.error("[validate.js] "+a)}}),d.validators={presence:function(a,b){return b=e.extend({},this.options,b),e.isEmpty(a)?b.message||this.message||"can't be blank":void 0},length:function(a,b,c){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var d,f=b.is,g=b.maximum,h=b.minimum,i=b.tokenizer||function(a){return a},j=[];a=i(a);var k=a.length;return e.isNumber(k)?(e.isNumber(f)&&k!==f&&(d=b.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",j.push(e.format(d,{count:f}))),e.isNumber(h)&&h>k&&(d=b.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",j.push(e.format(d,{count:h}))),e.isNumber(g)&&k>g&&(d=b.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",j.push(e.format(d,{count:g}))),j.length>0?b.message||j:void 0):(e.error(e.format("Attribute %{attr} has a non numeric value for `length`",{attr:c})),b.message||this.notValid||"has an incorrect length")}},numericality:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d,f=[],g={greaterThan:function(a,b){return a>b},greaterThanOrEqualTo:function(a,b){return a>=b},equalTo:function(a,b){return a===b},lessThan:function(a,b){return b>a},lessThanOrEqualTo:function(a,b){return b>=a}};if(b.noStrings!==!0&&e.isString(a)&&(a=+a),!e.isNumber(a))return b.message||b.notValid||this.notValid||"is not a number";if(b.onlyInteger&&!e.isInteger(a))return b.message||b.notInteger||this.notInteger||"must be an integer";for(c in g)if(d=b[c],e.isNumber(d)&&!g[c](a,d)){var h="not"+e.capitalize(c),i=b[h]||this[h]||"must be %{type} %{count}";f.push(e.format(i,{count:d,type:e.prettify(c)}))}return b.odd&&a%2!==1&&f.push(b.notOdd||this.notOdd||"must be odd"),b.even&&a%2!==0&&f.push(b.notEven||this.notEven||"must be even"),f.length?b.message||f:void 0}},datetime:e.extend(function(a,b){if(!e.isFunction(this.parse)||!e.isFunction(this.format))throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d=[],f=b.earliest?this.parse(b.earliest,b):0/0,g=b.latest?this.parse(b.latest,b):0/0;return a=this.parse(a,b),isNaN(a)||b.dateOnly&&a%864e5!==0?b.message||this.notValid||"must be a valid date":(!isNaN(f)&&f>a&&(c=this.tooEarly||"must be no earlier than %{date}",c=e.format(c,{date:this.format(f,b)}),d.push(c)),!isNaN(g)&&a>g&&(c=this.tooLate||"must be no later than %{date}",c=e.format(c,{date:this.format(g,b)}),d.push(c)),d.length?b.message||d:void 0)}},{parse:null,format:null}),date:function(a,b){return b=e.extend({},b,{dateOnly:!0}),e.validators.datetime.call(e.validators.datetime,a,b)},format:function(a,b){(e.isString(b)||b instanceof RegExp)&&(b={pattern:b}),b=e.extend({},this.options,b);var c,d=b.message||this.message||"is invalid",f=b.pattern;return e.isEmpty(a)?void 0:e.isString(a)?(e.isString(f)&&(f=new RegExp(b.pattern,b.flags)),c=f.exec(a),c&&c[0].length==a.length?void 0:d):d},inclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),!e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is not included in the list";return e.format(c,{value:a})}},exclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is restricted";return e.format(c,{value:a})}},email:e.extend(function(a,b){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid email";if(!e.isEmpty(a))return e.isString(a)&&this.PATTERN.exec(a)?void 0:c},{PATTERN:/^[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i}),equality:function(a,b,c,d){if(!e.isEmpty(a)){e.isString(b)&&(b={attribute:b}),b=e.extend({},this.options,b);var f=b.message||this.message||"is not equal to %{attribute}";if(e.isEmpty(b.attribute)||!e.isString(b.attribute))throw new Error("The attribute must be a non empty string");var g=e.getDeepObjectValue(d,b.attribute),h=b.comparator||function(a,b){return a===b};return h(a,g,b,c,d)?void 0:e.format(f,{attribute:e.prettify(b.attribute)})}},url:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid url",d=b.schemes||this.schemes||["http","https"],f=b.allowLocal||this.allowLocal||!1;if(!e.isString(a))return c;var g="^(?:(?:"+d.join("|")+"):\\/\\/)(?:\\S+(?::\\S*)?@)?";g+="(?:";var h="(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))";f?h="(?:localhost|"+h+")":g+="(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})",g+="(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|"+h+"(?::\\d{2,5})?(?:\\/[^\\s]*)?$";var i=new RegExp(g,"i");return i.exec(a)?void 0:c}}},d.exposeModule(d,this,a,b,c)}).call(this,"undefined"!=typeof exports?exports:null,"undefined"!=typeof module?module:null,"undefined"!=typeof define?define:null); | ||
(function(a,b,c){"use strict";var d=function(a,b,c){c=e.extend({},e.options,c);var f,g,h=e.runValidations(a,b,c);for(f in h)for(g in h[f])if(e.isPromise(h[f][g]))throw new Error("Use validate.async if you want support for promises");return d.processValidationResults(h,c)},e=d;e.extend=function(a){return[].slice.call(arguments,1).forEach(function(b){for(var c in b)a[c]=b[c]}),a},e.extend(d,{version:{major:0,minor:10,patch:0,metadata:null,toString:function(){var a=e.format("%{major}.%{minor}.%{patch}",e.version);return e.isEmpty(e.version.metadata)||(a+="+"+e.version.metadata),a}},Promise:"undefined"!=typeof Promise?Promise:null,EMPTY_STRING_REGEXP:/^\s*$/,runValidations:function(a,b,c){var d,f,g,h,i,j,k,l=[];(e.isDomElement(a)||e.isJqueryElement(a))&&(a=e.collectFormValues(a));for(d in b){g=e.getDeepObjectValue(a,d),h=e.result(b[d],g,a,d,c,b);for(f in h){if(i=e.validators[f],!i)throw k=e.format("Unknown validator %{name}",{name:f}),new Error(k);j=h[f],j=e.result(j,g,a,d,c,b),j&&l.push({attribute:d,value:g,validator:f,globalOptions:c,attributes:a,options:j,error:i.call(i,g,j,d,a,c)})}}return l},processValidationResults:function(a,b){var c;switch(a=e.pruneEmptyErrors(a,b),a=e.expandMultipleErrors(a,b),a=e.convertErrorMessages(a,b),b.format||"grouped"){case"detailed":break;case"flat":a=e.flattenErrorsToArray(a);break;case"grouped":a=e.groupErrorsByAttribute(a);for(c in a)a[c]=e.flattenErrorsToArray(a[c]);break;default:throw new Error(e.format("Unknown format %{format}",b))}return e.isEmpty(a)?void 0:a},async:function(a,b,c){c=e.extend({},e.async.options,c);var d=c.wrapErrors||function(a){return a};c.cleanAttributes!==!1&&(a=e.cleanAttributes(a,b));var f=e.runValidations(a,b,c);return new e.Promise(function(g,h){e.waitForResults(f).then(function(){var i=e.processValidationResults(f,c);i?h(new d(i,c,a,b)):g(a)},function(a){h(a)})})},single:function(a,b,c){return c=e.extend({},e.single.options,c,{format:"flat",fullMessages:!1}),e({single:a},{single:b},c)},waitForResults:function(a){return a.reduce(function(a,b){return e.isPromise(b.error)?a.then(function(){return b.error.then(function(a){b.error=a||null},function(a){if(a instanceof Error)throw a;e.error("Rejecting promises with the result is deprecated. Please use the resolve callback instead."),b.error=a})}):a},new e.Promise(function(a){a()}))},result:function(a){var b=[].slice.call(arguments,1);return"function"==typeof a&&(a=a.apply(null,b)),a},isNumber:function(a){return"number"==typeof a&&!isNaN(a)},isFunction:function(a){return"function"==typeof a},isInteger:function(a){return e.isNumber(a)&&a%1===0},isBoolean:function(a){return"boolean"==typeof a},isObject:function(a){return a===Object(a)},isDate:function(a){return a instanceof Date},isDefined:function(a){return null!==a&&void 0!==a},isPromise:function(a){return!!a&&e.isFunction(a.then)},isJqueryElement:function(a){return a&&e.isString(a.jquery)},isDomElement:function(a){return a&&a.querySelectorAll&&a.querySelector?e.isObject(document)&&a===document?!0:"object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName:!1},isEmpty:function(a){var b;if(!e.isDefined(a))return!0;if(e.isFunction(a))return!1;if(e.isString(a))return e.EMPTY_STRING_REGEXP.test(a);if(e.isArray(a))return 0===a.length;if(e.isDate(a))return!1;if(e.isObject(a)){for(b in a)return!1;return!0}return!1},format:e.extend(function(a,b){return e.isString(a)?a.replace(e.format.FORMAT_REGEXP,function(a,c,d){return"%"===c?"%{"+d+"}":String(b[d])}):a},{FORMAT_REGEXP:/(%?)%\{([^\}]+)\}/g}),prettify:function(a){return e.isNumber(a)?100*a%1===0?""+a:parseFloat(Math.round(100*a)/100).toFixed(2):e.isArray(a)?a.map(function(a){return e.prettify(a)}).join(", "):e.isObject(a)?a.toString():(a=""+a,a.replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(a,b,c){return""+b+" "+c.toLowerCase()}).toLowerCase())},stringifyValue:function(a){return e.prettify(a)},isString:function(a){return"string"==typeof a},isArray:function(a){return"[object Array]"==={}.toString.call(a)},isHash:function(a){return e.isObject(a)&&!e.isArray(a)&&!e.isFunction(a)},contains:function(a,b){return e.isDefined(a)?e.isArray(a)?-1!==a.indexOf(b):b in a:!1},unique:function(a){return e.isArray(a)?a.filter(function(a,b,c){return c.indexOf(a)==b}):a},forEachKeyInKeypath:function(a,b,c){if(e.isString(b)){var d,f="",g=!1;for(d=0;d<b.length;++d)switch(b[d]){case".":g?(g=!1,f+="."):(a=c(a,f,!1),f="");break;case"\\":g?(g=!1,f+="\\"):g=!0;break;default:g=!1,f+=b[d]}return c(a,f,!0)}},getDeepObjectValue:function(a,b){return e.isObject(a)?e.forEachKeyInKeypath(a,b,function(a,b){return e.isObject(a)?a[b]:void 0}):void 0},collectFormValues:function(a,b){var c,d,f,g,h={};if(e.isJqueryElement(a)&&(a=a[0]),!a)return h;for(b=b||{},f=a.querySelectorAll("input[name], textarea[name]"),c=0;c<f.length;++c)d=f.item(c),e.isDefined(d.getAttribute("data-ignored"))||(g=e.sanitizeFormValue(d.value,b),"number"===d.type?g=g?+g:null:"checkbox"===d.type?d.attributes.value?d.checked||(g=h[d.name]||null):g=d.checked:"radio"===d.type&&(d.checked||(g=h[d.name]||null)),h[d.name]=g);for(f=a.querySelectorAll("select[name]"),c=0;c<f.length;++c)d=f.item(c),g=e.sanitizeFormValue(d.options[d.selectedIndex].value,b),h[d.name]=g;return h},sanitizeFormValue:function(a,b){return b.trim&&e.isString(a)&&(a=a.trim()),b.nullify!==!1&&""===a?null:a},capitalize:function(a){return e.isString(a)?a[0].toUpperCase()+a.slice(1):a},pruneEmptyErrors:function(a){return a.filter(function(a){return!e.isEmpty(a.error)})},expandMultipleErrors:function(a){var b=[];return a.forEach(function(a){e.isArray(a.error)?a.error.forEach(function(c){b.push(e.extend({},a,{error:c}))}):b.push(a)}),b},convertErrorMessages:function(a,b){b=b||{};var c=[];return a.forEach(function(a){var d=e.result(a.error,a.value,a.attribute,a.options,a.attributes,a.globalOptions);return e.isString(d)?("^"===d[0]?d=d.slice(1):b.fullMessages!==!1&&(d=e.capitalize(e.prettify(a.attribute))+" "+d),d=d.replace(/\\\^/g,"^"),d=e.format(d,{value:e.stringifyValue(a.value)}),void c.push(e.extend({},a,{error:d}))):void c.push(a)}),c},groupErrorsByAttribute:function(a){var b={};return a.forEach(function(a){var c=b[a.attribute];c?c.push(a):b[a.attribute]=[a]}),b},flattenErrorsToArray:function(a){return a.map(function(a){return a.error})},cleanAttributes:function(a,b){function c(a,b,c){return e.isObject(a[b])?a[b]:a[b]=c?!0:{}}function d(a){var b,d={};for(b in a)a[b]&&e.forEachKeyInKeypath(d,b,c);return d}function f(a,b){if(!e.isObject(a))return a;var c,d,g=e.extend({},a);for(d in a)c=b[d],e.isObject(c)?g[d]=f(g[d],c):c||delete g[d];return g}return e.isObject(b)&&e.isObject(a)?(b=d(b),f(a,b)):{}},exposeModule:function(a,b,c,d,e){c?(d&&d.exports&&(c=d.exports=a),c.validate=a):(b.validate=a,a.isFunction(e)&&e.amd&&e([],function(){return a}))},warn:function(a){"undefined"!=typeof console&&console.warn&&console.warn("[validate.js] "+a)},error:function(a){"undefined"!=typeof console&&console.error&&console.error("[validate.js] "+a)}}),d.validators={presence:function(a,b){return b=e.extend({},this.options,b),e.isEmpty(a)?b.message||this.message||"can't be blank":void 0},length:function(a,b,c){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var d,f=b.is,g=b.maximum,h=b.minimum,i=b.tokenizer||function(a){return a},j=[];a=i(a);var k=a.length;return e.isNumber(k)?(e.isNumber(f)&&k!==f&&(d=b.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",j.push(e.format(d,{count:f}))),e.isNumber(h)&&h>k&&(d=b.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",j.push(e.format(d,{count:h}))),e.isNumber(g)&&k>g&&(d=b.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",j.push(e.format(d,{count:g}))),j.length>0?b.message||j:void 0):(e.error(e.format("Attribute %{attr} has a non numeric value for `length`",{attr:c})),b.message||this.notValid||"has an incorrect length")}},numericality:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d,f=[],g={greaterThan:function(a,b){return a>b},greaterThanOrEqualTo:function(a,b){return a>=b},equalTo:function(a,b){return a===b},lessThan:function(a,b){return b>a},lessThanOrEqualTo:function(a,b){return b>=a},divisibleBy:function(a,b){return a%b===0}};if(e.isString(a)&&b.strict){var h="^(0|[1-9]\\d*)";if(b.onlyInteger||(h+="(\\.\\d+)?"),h+="$",!new RegExp(h).test(a))return b.message||b.notValid||this.notValid||"must be a valid number"}if(b.noStrings!==!0&&e.isString(a)&&(a=+a),!e.isNumber(a))return b.message||b.notValid||this.notValid||"is not a number";if(b.onlyInteger&&!e.isInteger(a))return b.message||b.notInteger||this.notInteger||"must be an integer";for(c in g)if(d=b[c],e.isNumber(d)&&!g[c](a,d)){var i="not"+e.capitalize(c),j=b[i]||this[i]||"must be %{type} %{count}";f.push(e.format(j,{count:d,type:e.prettify(c)}))}return b.odd&&a%2!==1&&f.push(b.notOdd||this.notOdd||"must be odd"),b.even&&a%2!==0&&f.push(b.notEven||this.notEven||"must be even"),f.length?b.message||f:void 0}},datetime:e.extend(function(a,b){if(!e.isFunction(this.parse)||!e.isFunction(this.format))throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d=[],f=b.earliest?this.parse(b.earliest,b):NaN,g=b.latest?this.parse(b.latest,b):NaN;return a=this.parse(a,b),isNaN(a)||b.dateOnly&&a%864e5!==0?(c=b.notValid||b.message||this.notValid||"must be a valid date",e.format(c,{value:arguments[0]})):(!isNaN(f)&&f>a&&(c=b.tooEarly||b.message||this.tooEarly||"must be no earlier than %{date}",c=e.format(c,{value:this.format(a,b),date:this.format(f,b)}),d.push(c)),!isNaN(g)&&a>g&&(c=b.tooLate||b.message||this.tooLate||"must be no later than %{date}",c=e.format(c,{date:this.format(g,b),value:this.format(a,b)}),d.push(c)),d.length?e.unique(d):void 0)}},{parse:null,format:null}),date:function(a,b){return b=e.extend({},b,{dateOnly:!0}),e.validators.datetime.call(e.validators.datetime,a,b)},format:function(a,b){(e.isString(b)||b instanceof RegExp)&&(b={pattern:b}),b=e.extend({},this.options,b);var c,d=b.message||this.message||"is invalid",f=b.pattern;return e.isEmpty(a)?void 0:e.isString(a)?(e.isString(f)&&(f=new RegExp(b.pattern,b.flags)),c=f.exec(a),c&&c[0].length==a.length?void 0:d):d},inclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),!e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is not included in the list";return e.format(c,{value:a})}},exclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is restricted";return e.format(c,{value:a})}},email:e.extend(function(a,b){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid email";if(!e.isEmpty(a))return e.isString(a)&&this.PATTERN.exec(a)?void 0:c},{PATTERN:/^[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i}),equality:function(a,b,c,d){if(!e.isEmpty(a)){e.isString(b)&&(b={attribute:b}),b=e.extend({},this.options,b);var f=b.message||this.message||"is not equal to %{attribute}";if(e.isEmpty(b.attribute)||!e.isString(b.attribute))throw new Error("The attribute must be a non empty string");var g=e.getDeepObjectValue(d,b.attribute),h=b.comparator||function(a,b){return a===b};return h(a,g,b,c,d)?void 0:e.format(f,{attribute:e.prettify(b.attribute)})}},url:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid url",d=b.schemes||this.schemes||["http","https"],f=b.allowLocal||this.allowLocal||!1;if(!e.isString(a))return c;var g="^(?:(?:"+d.join("|")+"):\\/\\/)(?:\\S+(?::\\S*)?@)?";g+="(?:";var h="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";f?h+="?":g+="(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})";var i="(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*"+h+")";g+="(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|"+i+"(?::\\d{2,5})?(?:\\/[^\\s]*)?$";var j=new RegExp(g,"i");return j.exec(a)?void 0:c}}},d.exposeModule(d,this,a,b,c)}).call(this,"undefined"!=typeof exports?exports:null,"undefined"!=typeof module?module:null,"undefined"!=typeof define?define:null); | ||
//# sourceMappingURL=validate.min.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
1013566
51
5926
2
10