Socket
Socket
Sign inDemoInstall

anchor

Package Overview
Dependencies
Maintainers
4
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anchor - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

32

lib/rules.js

@@ -54,5 +54,6 @@ /**

fn: function(x, val) {
return typeof x === 'number' && x <= val;
if (typeof x !== 'number') { throw new Error ('Value was not a number.'); }
return x <= val;
},
defaultErrorMessage: function(x, val) { return 'Value was greater than the specified maximum (' + val + ')'; },
defaultErrorMessage: function(x, val) { return 'Value was greater than the configured maximum (' + val + ')'; },
expectedTypes: ['json', 'ref', 'number']

@@ -62,5 +63,6 @@ },

fn: function(x, val) {
return typeof x === 'number' && x >= val;
if (typeof x !== 'number') { throw new Error ('Value was not a number.'); }
return x >= val;
},
defaultErrorMessage: function(x, val) { return 'Value was less than the specified minimum (' + val + ')'; },
defaultErrorMessage: function(x, val) { return 'Value was less than the configured minimum (' + val + ')'; },
expectedTypes: ['json', 'ref', 'number']

@@ -76,3 +78,3 @@ },

expectedTypes: ['json', 'ref', 'string', 'number'],
defaultErrorMessage: function(x, val) { return 'Value was before the specified time (' + val + ')'; },
defaultErrorMessage: function(x, val) { return 'Value was before the configured time (' + val + ')'; },
ignoreEmptyString: true

@@ -83,3 +85,3 @@ },

expectedTypes: ['json', 'ref', 'string', 'number'],
defaultErrorMessage: function(x, val) { return 'Value was after the specified time (' + val + ')'; },
defaultErrorMessage: function(x, val) { return 'Value was after the configured time (' + val + ')'; },
ignoreEmptyString: true

@@ -108,3 +110,3 @@ },

expectedTypes: ['json', 'ref', 'string', 'number'],
defaultErrorMessage: function(x, val) { return 'Value was not in the specified whitelist (' + val.join(', ') + ')'; },
defaultErrorMessage: function(x, val) { return 'Value was not in the configured whitelist (' + val.join(', ') + ')'; },
ignoreEmptyString: true

@@ -123,3 +125,3 @@ },

expectedTypes: ['json', 'ref', 'string', 'number'],
defaultErrorMessage: function(x, val) { return 'Value was in the specified blacklist (' + val.join(', ') + ')'; },
defaultErrorMessage: function(x, val) { return 'Value was in the configured blacklist (' + val.join(', ') + ')'; },
ignoreEmptyString: true

@@ -144,6 +146,7 @@ },

fn: function(x, min) {
return typeof x === 'string' && validator.isLength(x, min);
if (typeof x !== 'string') { throw new Error ('Value was not a string.'); }
return validator.isLength(x, min);
},
expectedTypes: ['json', 'ref', 'string'],
defaultErrorMessage: function(x, val) { return 'Value was shorter than the specified minimum length (' + val + ')'; },
defaultErrorMessage: function(x, val) { return 'Value was shorter than the configured minimum length (' + val + ')'; },
ignoreEmptyString: true

@@ -153,6 +156,7 @@ },

fn: function(x, max) {
return typeof x === 'string' && validator.isLength(x, 0, max);
if (typeof x !== 'string') { throw new Error ('Value was not a string.'); }
return validator.isLength(x, 0, max);
},
expectedTypes: ['json', 'ref', 'string'],
defaultErrorMessage: function(x, val) { return 'Value was longer than the specified maximum length (' + val + ')'; },
defaultErrorMessage: function(x, val) { return 'Value was longer than the configured maximum length (' + val + ')'; },
ignoreEmptyString: true

@@ -164,7 +168,7 @@ },

if (!_.isRegExp(regex)) {
throw new Error('This rule expects a regular expression to be provided, but instead got the ' + typeof regex + ' `' + util.inspect(regex) + '`.');
throw new Error('This rule expects a regular expression to be configured, but instead got the ' + typeof regex + ' `' + util.inspect(regex) + '`.');
}
return validator.matches(x, regex);
},
defaultErrorMessage: function(x, val) { return 'Value did not match the specified regular expression (' + val + ')'; },
defaultErrorMessage: function(x, val) { return 'Value did not match the configured regular expression (' + val + ')'; },
expectedTypes: ['json', 'ref', 'string'],

@@ -171,0 +175,0 @@ ignoreEmptyString: true

{
"name": "anchor",
"version": "1.1.0",
"version": "1.1.1",
"description": "Recursive validation library with support for objects and lists",

@@ -5,0 +5,0 @@ "homepage": "http://sailsjs.org",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc