Comparing version 0.11.5 to 1.0.0
@@ -7,3 +7,2 @@ /** | ||
var validator = require('validator'); | ||
var geojsonhint = require('@mapbox/geojsonhint'); | ||
@@ -16,115 +15,15 @@ /** | ||
'empty' : _.isEmpty, | ||
'required' : function (x) { | ||
// Transform data to work properly with node validator | ||
if(!x && x !== 0 && x !== false) { x = ''; } | ||
else if(typeof x.toString !== 'undefined') { x = x.toString(); } | ||
else { x = '' + x; } | ||
return !validator.isNull(x); | ||
// Note that this (^^) is probably not the expected behavior! | ||
// | ||
// Because: | ||
// ``` | ||
// require('validator').isNull([]) >> true | ||
// ``` | ||
// | ||
// This will change in a future release of anchor. | ||
}, | ||
'protected' : function () {return true;}, | ||
'notEmpty' : function (x) { | ||
// Transform data to work properly with node validator | ||
if (!x) { | ||
x = ''; | ||
} | ||
else if (typeof x.toString !== 'undefined') { | ||
x = x.toString(); | ||
} | ||
else { | ||
x = '' + x; | ||
} | ||
return !validator.isNull(x); | ||
}, | ||
'undefined' : _.isUndefined, | ||
'object' : _.isObject, | ||
'json' : function (x) { | ||
if (_.isUndefined(x)) { return false; } | ||
try { JSON.stringify(x); } | ||
catch(err) { return false; } | ||
return true; | ||
}, | ||
'geojson' : function (value, opt) { | ||
var errors = geojsonhint.hint(value); | ||
return errors.length === 0; | ||
}, | ||
'geometry': function (value) { | ||
return _.isEmpty(value) || (_.isObject(value) || _.isString(value)); | ||
}, | ||
'mediumtext' : _.isString, | ||
'longtext' : _.isString, | ||
'text' : _.isString, | ||
'string' : _.isString, | ||
'alpha' : validator.isAlpha, | ||
'alphadashed': function (x) {return (/^[a-zA-Z-_]*$/).test(x); }, | ||
'numeric' : validator.isNumeric, | ||
'alphanumeric': validator.isAlphanumeric, | ||
'alphanumericdashed': function (x) {return (/^[a-zA-Z0-9-_]*$/).test(x); }, | ||
'email' : validator.isEmail, | ||
'url' : function(x, opt) { return validator.isURL(x, opt === true ? undefined : opt); }, | ||
'urlish' : function (x) { | ||
return !!validator.matches(x, /^\s([^\/]+\.)+.+\s*$/g); | ||
}, | ||
'ip' : validator.isIP, | ||
'ipv4' : validator.isIPv4, | ||
'ipv6' : validator.isIPv6, | ||
'creditcard': validator.isCreditCard, | ||
'uuid' : validator.isUUID, | ||
'uuidv3' : function (x){ return validator.isUUID(x, 3);}, | ||
'uuidv4' : function (x){ return validator.isUUID(x, 4);}, | ||
'int' : validator.isInt, | ||
'integer' : validator.isInt, | ||
'number' : _.isNumber, | ||
'finite' : _.isFinite, | ||
'decimal' : validator.isFloat, | ||
'float' : validator.isFloat, | ||
'falsey' : function (x) { return !x; }, | ||
'truthy' : function (x) { return !!x; }, | ||
'null' : _.isNull, | ||
'notNull' : function (x) { return !validator.isNull(x); }, | ||
'boolean' : _.isBoolean, | ||
'array' : _.isArray, | ||
'binary' : function (x) { return Buffer.isBuffer(x) || _.isString(x); }, | ||
'date' : validator.isDate, | ||
'datetime': validator.isDate, | ||
'hexadecimal': validator.isHexadecimal, | ||
'hexColor': validator.isHexColor, | ||
'lowercase': validator.isLowercase, | ||
'uppercase': validator.isUppercase, | ||
'isEmail' : validator.isEmail, | ||
'isURL' : function(x, opt) { return validator.isURL(x, opt === true ? undefined : opt); }, | ||
'isIP' : validator.isIP, | ||
'isCreditCard': validator.isCreditCard, | ||
'isUUID' : validator.isUUID, | ||
'isInteger' : validator.isInt, | ||
'isHexColor': validator.isHexColor, | ||
// Miscellaneous rules | ||
'after' : validator.isAfter, | ||
'before' : validator.isBefore, | ||
'equals' : validator.equals, | ||
'contains': validator.contains, | ||
'notContains': function (x, str) { return !validator.contains(x, str); }, | ||
'in' : validator.isIn, | ||
'notIn' : function (x, arrayOrString) { return !validator.isIn(x, arrayOrString); }, | ||
'isAfter' : validator.isAfter, | ||
'isBefore' : validator.isBefore, | ||
'enum' : validator.isIn, | ||
'isIn' : validator.isIn, | ||
'isNotIn' : function (x, arrayOrString) { return !validator.isIn(x, arrayOrString); }, | ||
'max' : function (x, val) { | ||
@@ -138,17 +37,4 @@ var number = parseFloat(x); | ||
}, | ||
'greaterThan' : function (x, val) { | ||
var number = parseFloat(x); | ||
return isNaN(number) || number > val; | ||
}, | ||
'lessThan' : function (x, val) { | ||
var number = parseFloat(x); | ||
return isNaN(number) || number < val; | ||
}, | ||
'minLength' : function (x, min) { return validator.isLength(x, min); }, | ||
'maxLength' : function (x, max) { return validator.isLength(x, 0, max); }, | ||
'is' : function (x, regex) { | ||
if (!_.isRegExp(regex)) { throw new Error('`regex` (aka `is`) validation rule must be provided a true regular expression (instead got `'+typeof regex+'`)'); } | ||
return validator.matches(x, regex); | ||
}, | ||
'regex' : function (x, regex) { | ||
@@ -158,7 +44,5 @@ if (!_.isRegExp(regex)) { throw new Error('`regex` validation rule must be provided a true regular expression (instead got `'+typeof regex+'`)'); } | ||
}, | ||
'notRegex' : function (x, regex) { | ||
if (!_.isRegExp(regex)) { throw new Error('`notRegex` validation rule must be provided a true regular expression (instead got `'+typeof regex+'`)'); } | ||
return !validator.matches(x, regex); | ||
}, | ||
'custom': function(x, fn) { | ||
return fn(x); | ||
} | ||
}; |
{ | ||
"name": "anchor", | ||
"version": "0.11.5", | ||
"version": "1.0.0", | ||
"description": "Recursive validation library with support for objects and lists", | ||
@@ -34,3 +34,2 @@ "homepage": "http://sailsjs.org", | ||
"dependencies": { | ||
"@mapbox/geojsonhint": "1.2.1", | ||
"@sailshq/lodash": "^3.10.2", | ||
@@ -37,0 +36,0 @@ "validator": "4.4.0" |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2
12
0
22653
582
- Removed@mapbox/geojsonhint@1.2.1
- Removed@mapbox/geojsonhint@1.2.1(transitive)
- RemovedJSV@4.0.2(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@1.0.02.2.1(transitive)
- Removedchalk@0.4.01.1.3(transitive)
- Removedconcat-stream@1.4.11(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-color@0.1.7(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@0.0.1(transitive)
- Removedjsonlint-lines@1.7.1(transitive)
- Removedminimist@1.1.1(transitive)
- Removednomnom@1.8.1(transitive)
- Removedreadable-stream@1.1.14(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedstrip-ansi@0.1.13.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedtext-table@0.2.0(transitive)
- Removedtypedarray@0.0.7(transitive)
- Removedunderscore@1.6.0(transitive)