Socket
Socket
Sign inDemoInstall

validator

Package Overview
Dependencies
Maintainers
1
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

validator - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

2

lib/filter.js
var entities = require('./entities');
xss = require('./xss');
var xss = require('./xss');

@@ -4,0 +4,0 @@ var Filter = exports.Filter = function() {}

@@ -116,3 +116,3 @@ var net = require('net');

Validator.prototype.isInt = function() {
if (!this.str.match(/^(?:-?(?:0|[1-9][0-9]*))$/)) {
if (!this.str.match(/^(?:-?(?:[0-9][0-9]*)(?:\.?0+)?)$/)) {
return this.error(this.msg || 'Invalid integer');

@@ -124,3 +124,3 @@ }

Validator.prototype.isDecimal = function() {
if (!this.str.match(/^(?:-?(?:0|[1-9][0-9]*))?(?:\.[0-9]*)?$/)) {
if (this.str === '' || !this.str.match(/^(?:-?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/)) {
return this.error(this.msg || 'Invalid decimal');

@@ -127,0 +127,0 @@ }

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

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

@@ -201,8 +201,16 @@ var node_validator = require('../lib'),

assert.ok(Validator.check('-0').isInt());
assert.ok(Validator.check('01').isInt());
assert.ok(Validator.check('-01').isInt());
assert.ok(Validator.check('000').isInt());
['123.123','01','000',' ',''].forEach(function(str) {
['123.123',' ',''].forEach(function(str) {
try {
Validator.check(str).isInt();
assert.ok(false, 'isInt failed');
} catch (e) {}
assert.ok(false, 'falsepositive');
} catch (e) {
if (e.message == 'falsepositive') {
e.message = 'isInt had a false positive: ' + str;
throw e;
}
}
});

@@ -221,8 +229,18 @@ },

assert.ok(Validator.check('-0').isDecimal());
assert.ok(Validator.check('01.123').isDecimal());
['-.123','01.123',' ',''].forEach(function(str) {
assert.ok(Validator.check('2.2250738585072011e-308').isDecimal());
assert.ok(Validator.check('-0.22250738585072011e-307').isDecimal());
assert.ok(Validator.check('-0.22250738585072011E-307').isDecimal());
['-.123',' ',''].forEach(function(str) {
try {
Validator.check(str).isDecimal();
assert.ok(false, 'isDecimal failed');
} catch (e) {}
assert.ok(false, 'falsepositive');
} catch (e) {
if (e.message == 'falsepositive') {
e.message = 'isDecimal had a false positive: ' + str;
throw e;
}
}
});

@@ -229,0 +247,0 @@ },

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