Socket
Socket
Sign inDemoInstall

validator

Package Overview
Dependencies
0
Maintainers
0
Versions
211
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.3 to 0.2.4

14

lib/validator.js

@@ -208,1 +208,15 @@ var net = require('net');

};
Validator.prototype.in = function(options) {
//Syntactic sugar for string-in-string
if (options && typeof options.indexOf === 'function') {
if (! ~options.indexOf(this.str)) {
return this.error(this.msg || 'Unexpected value');
}
return this;
}
else {
return this.error(this.msg || 'Invalid in() argument');
}
};

2

package.json
{ "name" : "validator",
"description" : "Data validation, filtering and sanitization for node.js",
"version" : "0.2.3",
"version" : "0.2.4",
"homepage" : "http://github.com/chriso/node-validator",

@@ -5,0 +5,0 @@ "keywords" : ["validator", "validation", "assert", "params", "sanitization", "xss", "entities", "sanitize", "sanitisation", "input"],

@@ -75,2 +75,3 @@ **node-validator is a library of string validation, filtering and sanitization methods.**

len(min, max) //max is optional
in(options) //Accepts an array or string

@@ -77,0 +78,0 @@ ## List of sanitization / filter methods

@@ -393,5 +393,34 @@ var node_validator = require('../lib'),

},
'test #in(options)': function () {
assert.ok(Validator.check('foo').in('foobar'));
assert.ok(Validator.check('foo').in('I love football'));
assert.ok(Validator.check('foo').in(['foo', 'bar', 'baz']));
assert.throws(function() {
Validator.check('foo').in(['bar', 'baz']);
}, /unexpected/i
);
assert.throws(function() {
Validator.check('foo').in('bar, baz');
}, /unexpected/i
);
assert.throws(function() {
Validator.check('foo').in(1234567);
}, /invalid/i
);
assert.throws(function() {
Validator.check('foo').in({foo:"foo",bar:"bar"});
}, /invalid/i
);
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc