Comparing version 1.3.0 to 1.4.0
@@ -22,3 +22,3 @@ /** | ||
}, | ||
defaultErrorMessage: 'Value was not a boolean.', | ||
defaultErrorMessage: function(x) { return 'Value ('+util.inspect(x)+') was not a boolean.'; }, | ||
expectedTypes: ['json', 'ref'] | ||
@@ -30,3 +30,3 @@ }, | ||
}, | ||
defaultErrorMessage: 'Value was an empty string.', | ||
defaultErrorMessage: function(x) { return 'Value ('+util.inspect(x)+') was an empty string.'; }, | ||
expectedTypes: ['json', 'ref', 'string'] | ||
@@ -38,3 +38,3 @@ }, | ||
}, | ||
defaultErrorMessage: 'Value was not an integer.', | ||
defaultErrorMessage: function(x) { return 'Value ('+util.inspect(x)+') was not an integer.'; }, | ||
expectedTypes: ['json', 'ref', 'number'] | ||
@@ -46,3 +46,3 @@ }, | ||
}, | ||
defaultErrorMessage: 'Value was not a number.', | ||
defaultErrorMessage: function(x) { return 'Value ('+util.inspect(x)+') was not a number.'; }, | ||
expectedTypes: ['json', 'ref'] | ||
@@ -54,11 +54,11 @@ }, | ||
}, | ||
defaultErrorMessage: 'Value was not a string.', | ||
defaultErrorMessage: function(x) { return 'Value ('+util.inspect(x)+') was not a string.'; }, | ||
expectedTypes: ['json', 'ref'] | ||
}, | ||
'max': { | ||
fn: function(x, val) { | ||
fn: function(x, maximum) { | ||
if (typeof x !== 'number') { throw new Error ('Value was not a number.'); } | ||
return x <= val; | ||
return x <= maximum; | ||
}, | ||
defaultErrorMessage: function(x, val) { return 'Value was greater than the configured maximum (' + val + ')'; }, | ||
defaultErrorMessage: function(x, maximum) { return 'Value ('+util.inspect(x)+') was greater than the configured maximum (' + maximum + ')'; }, | ||
expectedTypes: ['json', 'ref', 'number'], | ||
@@ -73,7 +73,7 @@ checkConfig: function(constraint) { | ||
'min': { | ||
fn: function(x, val) { | ||
fn: function(x, minimum) { | ||
if (typeof x !== 'number') { throw new Error ('Value was not a number.'); } | ||
return x >= val; | ||
return x >= minimum; | ||
}, | ||
defaultErrorMessage: function(x, val) { return 'Value was less than the configured minimum (' + val + ')'; }, | ||
defaultErrorMessage: function(x, minimum) { return 'Value ('+util.inspect(x)+') was less than the configured minimum (' + minimum + ')'; }, | ||
expectedTypes: ['json', 'ref', 'number'], | ||
@@ -116,3 +116,3 @@ checkConfig: function(constraint) { | ||
expectedTypes: ['json', 'ref', 'string', 'number'], | ||
defaultErrorMessage: function(x, val) { return 'Value was before the configured time (' + val + ')'; }, | ||
defaultErrorMessage: function(x, constraint) { return 'Value ('+util.inspect(x)+') was before the configured time (' + constraint + ')'; }, | ||
ignoreEmptyString: true, | ||
@@ -153,3 +153,3 @@ checkConfig: function(constraint) { | ||
expectedTypes: ['json', 'ref', 'string', 'number'], | ||
defaultErrorMessage: function(x, val) { return 'Value was after the configured time (' + val + ')'; }, | ||
defaultErrorMessage: function(x, constraint) { return 'Value ('+util.inspect(x)+') was after the configured time (' + constraint + ')'; }, | ||
ignoreEmptyString: true, | ||
@@ -171,3 +171,3 @@ checkConfig: function(constraint) { | ||
expectedTypes: ['json', 'ref', 'string'], | ||
defaultErrorMessage: 'Value was not a valid credit card.', | ||
defaultErrorMessage: function () { return 'Value was not a valid credit card.'; }, | ||
ignoreEmptyString: true | ||
@@ -181,3 +181,3 @@ }, | ||
expectedTypes: ['json', 'ref', 'string'], | ||
defaultErrorMessage: 'Value was not a valid email address.', | ||
defaultErrorMessage: function (x) { return 'Value ('+util.inspect(x)+') was not a valid email address.'; }, | ||
ignoreEmptyString: true | ||
@@ -191,3 +191,3 @@ }, | ||
expectedTypes: ['json', 'ref', 'string'], | ||
defaultErrorMessage: 'Value was not a valid hex color.', | ||
defaultErrorMessage: function (x) { return 'Value ('+util.inspect(x)+') was not a valid hex color.'; }, | ||
ignoreEmptyString: true | ||
@@ -200,3 +200,3 @@ }, | ||
expectedTypes: ['json', 'ref', 'string', 'number'], | ||
defaultErrorMessage: function(x, val) { return 'Value was not in the configured whitelist (' + val.join(', ') + ')'; }, | ||
defaultErrorMessage: function(x, whitelist) { return 'Value ('+util.inspect(x)+') was not in the configured whitelist (' + whitelist.join(', ') + ')'; }, | ||
ignoreEmptyString: true, | ||
@@ -217,3 +217,3 @@ checkConfig: function(constraint) { | ||
expectedTypes: ['json', 'ref', 'string'], | ||
defaultErrorMessage: 'Value was not a valid IP address.', | ||
defaultErrorMessage: function (x) { return 'Value ('+util.inspect(x)+') was not a valid IP address.'; }, | ||
ignoreEmptyString: true | ||
@@ -226,3 +226,3 @@ }, | ||
expectedTypes: ['json', 'ref', 'string', 'number'], | ||
defaultErrorMessage: function(x, val) { return 'Value was in the configured blacklist (' + val.join(', ') + ')'; }, | ||
defaultErrorMessage: function(x, blacklist) { return 'Value ('+util.inspect(x)+') was in the configured blacklist (' + blacklist.join(', ') + ')'; }, | ||
ignoreEmptyString: true, | ||
@@ -242,3 +242,3 @@ checkConfig: function(constraint) { | ||
expectedTypes: ['json', 'ref', 'string'], | ||
defaultErrorMessage: 'Value was not a valid URL.', | ||
defaultErrorMessage: function (x) { return 'Value ('+util.inspect(x)+') was not a valid URL.'; }, | ||
ignoreEmptyString: true | ||
@@ -252,3 +252,3 @@ }, | ||
expectedTypes: ['json', 'ref', 'string'], | ||
defaultErrorMessage: 'Value was not a valid UUID.', | ||
defaultErrorMessage: function (x) { return 'Value ('+util.inspect(x)+') was not a valid UUID.'; }, | ||
ignoreEmptyString: true | ||
@@ -258,8 +258,8 @@ }, | ||
'minLength': { | ||
fn: function(x, min) { | ||
fn: function(x, minLength) { | ||
if (typeof x !== 'string') { throw new Error ('Value was not a string.'); } | ||
return x.length >= min; | ||
return x.length >= minLength; | ||
}, | ||
expectedTypes: ['json', 'ref', 'string'], | ||
defaultErrorMessage: function(x, val) { return 'Value was shorter than the configured minimum length (' + val + ')'; }, | ||
defaultErrorMessage: function(x, minLength) { return 'Value ('+util.inspect(x)+') was shorter than the configured minimum length (' + minLength + ')'; }, | ||
ignoreEmptyString: true, | ||
@@ -274,8 +274,8 @@ checkConfig: function(constraint) { | ||
'maxLength': { | ||
fn: function(x, max) { | ||
fn: function(x, maxLength) { | ||
if (typeof x !== 'string') { throw new Error ('Value was not a string.'); } | ||
return x.length <= max; | ||
return x.length <= maxLength; | ||
}, | ||
expectedTypes: ['json', 'ref', 'string'], | ||
defaultErrorMessage: function(x, val) { return 'Value was longer than the configured maximum length (' + val + ')'; }, | ||
defaultErrorMessage: function(x, maxLength) { return 'Value was '+(maxLength-x.length)+' character'+((maxLength-x.length !== 1) ? 's' : '')+' longer than the configured maximum length (' + maxLength + ')'; }, | ||
ignoreEmptyString: true, | ||
@@ -295,3 +295,3 @@ checkConfig: function(constraint) { | ||
}, | ||
defaultErrorMessage: function(x, val) { return 'Value did not match the configured regular expression (' + val + ')'; }, | ||
defaultErrorMessage: function(x, regex) { return 'Value ('+util.inspect(x)+') did not match the configured regular expression (' + regex + ')'; }, | ||
expectedTypes: ['json', 'ref', 'string'], | ||
@@ -313,7 +313,7 @@ ignoreEmptyString: true, | ||
'custom': { | ||
fn: function(x, fn) { | ||
return fn(x); | ||
fn: function(x, customFn) { | ||
return customFn(x); | ||
}, | ||
expectedTypes: ['json', 'ref', 'string', 'number', 'boolean'], | ||
defaultErrorMessage: 'Value failed custom validation.', | ||
defaultErrorMessage: function (x) { return 'Value ('+util.inspect(x)+') failed custom validation.'; }, | ||
checkConfig: function(constraint) { | ||
@@ -371,3 +371,3 @@ if (!_.isFunction(constraint)) { | ||
}; | ||
};//ƒ | ||
@@ -374,0 +374,0 @@ // If the rule doesn't declare its own config-checker, assume that the constraint is supposed to be `true`. |
{ | ||
"name": "anchor", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "High-level validation library for Node.js (used in Waterline)", | ||
@@ -5,0 +5,0 @@ "homepage": "https://sailsjs.com", |
@@ -14,3 +14,3 @@ var util = require('util'); | ||
if (exampleOutcome.length > 0) { | ||
throw new Error('Valid input marked with error: '+util.inspect(exampleOutcome,{depth:null})+ '\nExample: '+util.inspect(example,{depth:null})); | ||
throw new Error('Valid input marked with error: '+util.inspect(exampleOutcome,{depth:null})+ '\nExample: '+util.inspect(example,{depth:null})+'\nDetails: '+util.inspect(exampleOutcome)); | ||
} | ||
@@ -20,5 +20,5 @@ | ||
if (!_.isArray(nonexampleOutcome) || nonexampleOutcome.length === 0) { | ||
throw new Error('Invalid input (' + nonexample + ') allowed through. '+util.inspect(rules,{depth:null})+ '\nNon-example: '+util.inspect(nonexample,{depth:null})); | ||
throw new Error('Invalid input (' + nonexample + ') allowed through. '+util.inspect(rules,{depth:null})+ '\nNon-example: '+util.inspect(nonexample,{depth:null})+'\nDetails: '+util.inspect(nonexampleOutcome)); | ||
} | ||
}; |
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
40748