Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-validator

Package Overview
Dependencies
Maintainers
3
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-validator - npm Package Compare versions

Comparing version 4.2.0 to 4.2.1

tst.js

0

check/check-all.js

@@ -0,0 +0,0 @@ const check = require('./check');

const check = require('./check');
module.exports = (fields, message) => check(fields, ['body'], message);
const check = require('./check');
module.exports = (fields, message) => check(fields, ['cookies'], message);
const check = require('./check');
module.exports = (fields, message) => check(fields, ['headers'], message);
const check = require('./check');
module.exports = (fields, message) => check(fields, ['params'], message);
const check = require('./check');
module.exports = (fields, message) => check(fields, ['query'], message);

@@ -0,0 +0,0 @@ const validator = require('validator');

@@ -0,0 +0,0 @@ import * as express from 'express';

@@ -0,0 +0,0 @@ exports.check = require('./check-all');

@@ -0,0 +0,0 @@ const _ = require('lodash');

13

check/runner.js

@@ -0,1 +1,2 @@

const toString = require('../utils/to-string');
const selectFields = require('./select-fields');

@@ -28,12 +29,2 @@

return Promise.all(promises).then(() => validationErrors);
};
function toString(value) {
if (value && typeof value === 'object' && value.toString) {
return value.toString();
} else if (value == null || (isNaN(value) && !value.length)) {
return '';
}
return String(value);
}
};

@@ -63,5 +63,7 @@ const _ = require('lodash');

return field => sanitizers.reduce((prev, sanitizer) => {
return Object.assign({}, prev, {
value: sanitizer.sanitizer(prev.value, ...sanitizer.options)
});
const value = typeof prev.value === 'string' ?
sanitizer.sanitizer(prev.value, ...sanitizer.options) :
prev.value;
return Object.assign({}, prev, { value });
}, field);

@@ -68,0 +70,0 @@ }

@@ -0,0 +0,0 @@ module.exports = req => decorateAsValidationResult({}, req._validationErrors);

@@ -0,0 +0,0 @@ # Contributing to express-validator

@@ -0,0 +0,0 @@ import * as express from 'express';

@@ -0,0 +0,0 @@ exports.matchedData = require('./matched-data');

@@ -0,0 +0,0 @@ const _ = require('lodash');

const sanitize = require('./sanitize');
module.exports = fields => sanitize(fields, ['body', 'cookies', 'params', 'query']);
const sanitize = require('./sanitize');
module.exports = fields => sanitize(fields, ['body']);
const sanitize = require('./sanitize');
module.exports = fields => sanitize(fields, ['cookies']);
const sanitize = require('./sanitize');
module.exports = fields => sanitize(fields, ['params']);

@@ -11,35 +11,2 @@ var validator = require('validator');

// When validator upgraded to v5, they removed automatic string coercion
// The next few methods (up to validator.init()) restores that functionality
// so that express-validator can continue to function normally
validator.extend = function(name, fn) {
validator[name] = function() {
var args = Array.prototype.slice.call(arguments);
args[0] = validator.toString(args[0]);
return fn.apply(validator, args);
};
};
validator.init = function() {
for (var name in validator) {
if (typeof validator[name] !== 'function' || name === 'toString' ||
name === 'toDate' || name === 'extend' || name === 'init' ||
name === 'isServerSide') {
continue;
}
validator.extend(name, validator[name]);
}
};
validator.toString = function(input) {
if (typeof input === 'object' && input !== null && input.toString) {
input = input.toString();
} else if (input === null || typeof input === 'undefined' || (isNaN(input) && !input.length)) {
input = '';
}
return '' + input;
};
validator.init();
// validators and sanitizers not prefixed with is/to

@@ -112,2 +79,3 @@ var additionalSanitizers = ['trim', 'ltrim', 'rtrim', 'escape', 'unescape', 'stripLow', 'whitelist', 'blacklist', 'normalizeEmail'];

options,
custom: true,
negated: chain._context.negateNext,

@@ -248,3 +216,7 @@ validator: customValidators[name]

const promises = context.validators.map(validatorCfg => {
const result = validatorCfg.validator(field.value, ...validatorCfg.options);
const result = validatorCfg.validator(
validatorCfg.custom ? field.value : utils.toString(field.value),
...validatorCfg.options
);
const errorObj = {

@@ -251,0 +223,0 @@ location: field.location,

@@ -5,3 +5,4 @@ module.exports = exports = {

makeSanitizer: require('../utils/make-sanitizer'),
toString: require('../utils/to-string'),
replaceArgs: require('../utils/replace-args')
};

@@ -14,3 +14,3 @@ {

],
"version": "4.2.0",
"version": "4.2.1",
"homepage": "https://github.com/ctavan/express-validator",

@@ -17,0 +17,0 @@ "license": "MIT",

@@ -76,3 +76,3 @@ # express-validator

if (!errors.isEmpty()) {
return res.status(422).json({ errors: err.mapped() });
return res.status(422).json({ errors: errors.mapped() });
}

@@ -79,0 +79,0 @@

@@ -0,0 +0,0 @@ # Version 3 to Version 4 Upgrade Guide

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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