Skip to content

Commit

Permalink
chore(deps): refactor for latest Lodash compat. Also trims vulns.
Browse files Browse the repository at this point in the history
Closes z0mt3c#86
Closes z0mt3c#87
  • Loading branch information
tdd committed Apr 23, 2022
1 parent 6ef778d commit 5ff84d3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 51 deletions.
16 changes: 14 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
- Dependency updates (esp. vulns) -- see https://github.com/z0mt3c/node-restify-validation/pull/87
- Dependency updates (esp. vulns)

Lodash:

Closes https://github.com/z0mt3c/node-restify-validation/issues/86
Closes https://github.com/z0mt3c/node-restify-validation/pull/87

Mocha, Supertest (high priority)
Coveralls (removal? Is it even used?)
Should
Sinon
Validator (will likely require TONS of updates)

- Ensure all Validator.js features are properly exposed and use proper messaging
- Code cleanup within lib (ES2015+, strict mode)
- Migrate from Mocha / should to Jest
Expand All @@ -7,5 +19,5 @@
- Setup Travis CI; check badge
- Migrate from Coveralls to Codecov; check badge
- Add Dependabot badges etc.
- Restore all required parts of README (conditional checks, etc.)
- Restore when applicable stripped parts of README (conditional checks, etc.)
- Deprecate content/resources/queries in favor of body/params/query
2 changes: 1 addition & 1 deletion lib/conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports.paramMatches = function (params) {
return conditionalChecker(params, function (matches, value) {
var result
if (_.isArray(matches)) {
result = _.contains(matches, value)
result = _.includes(matches, value)
} else {
result = _.isEqual(matches, value)
}
Expand Down
7 changes: 3 additions & 4 deletions lib/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var validators = (module.exports = {
var renamedElements = {}
var keyError = _.reduce(
submittedValue,
function (previousError, value, key) {
(previousError, value, key) => {
if (previousError) {
return previousError
}
Expand All @@ -92,8 +92,7 @@ var validators = (module.exports = {
}
return validateKey.error
},
false,
this
false
)
// Merge renamed elements
_.extend(submittedValue, renamedElements)
Expand Down Expand Up @@ -155,7 +154,7 @@ function validateCollectionValues(context, collection, validationRules) {
}

var notSupported = ['len', 'notNull', 'isNull', 'notEmpty']
var validatorFunctionKeys = _.difference(_.functions(validator), notSupported)
var validatorFunctionKeys = _.difference(_.functionsIn(validator), notSupported)

_.each(validatorFunctionKeys, function (element, index, array) {
if (!_.has(validators, element)) {
Expand Down
53 changes: 10 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"node": ">= 8"
},
"dependencies": {
"lodash": "3.10.x",
"lodash": "^4.17.21",
"validator": "3.22.x"
},
"peerDependencies": {
Expand Down

0 comments on commit 5ff84d3

Please sign in to comment.