Skip to content

Commit 5ff84d3

Browse files
committed
chore(deps): refactor for latest Lodash compat. Also trims vulns.
Closes z0mt3c#86 Closes z0mt3c#87
1 parent 6ef778d commit 5ff84d3

File tree

5 files changed

+29
-51
lines changed

5 files changed

+29
-51
lines changed

TODO.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
- Dependency updates (esp. vulns) -- see https://github.com/z0mt3c/node-restify-validation/pull/87
1+
- Dependency updates (esp. vulns)
2+
3+
Lodash:
4+
5+
Closes https://github.com/z0mt3c/node-restify-validation/issues/86
6+
Closes https://github.com/z0mt3c/node-restify-validation/pull/87
7+
8+
Mocha, Supertest (high priority)
9+
Coveralls (removal? Is it even used?)
10+
Should
11+
Sinon
12+
Validator (will likely require TONS of updates)
13+
214
- Ensure all Validator.js features are properly exposed and use proper messaging
315
- Code cleanup within lib (ES2015+, strict mode)
416
- Migrate from Mocha / should to Jest
@@ -7,5 +19,5 @@
719
- Setup Travis CI; check badge
820
- Migrate from Coveralls to Codecov; check badge
921
- Add Dependabot badges etc.
10-
- Restore all required parts of README (conditional checks, etc.)
22+
- Restore when applicable stripped parts of README (conditional checks, etc.)
1123
- Deprecate content/resources/queries in favor of body/params/query

lib/conditions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports.paramMatches = function (params) {
55
return conditionalChecker(params, function (matches, value) {
66
var result
77
if (_.isArray(matches)) {
8-
result = _.contains(matches, value)
8+
result = _.includes(matches, value)
99
} else {
1010
result = _.isEqual(matches, value)
1111
}

lib/validators.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ var validators = (module.exports = {
7676
var renamedElements = {}
7777
var keyError = _.reduce(
7878
submittedValue,
79-
function (previousError, value, key) {
79+
(previousError, value, key) => {
8080
if (previousError) {
8181
return previousError
8282
}
@@ -92,8 +92,7 @@ var validators = (module.exports = {
9292
}
9393
return validateKey.error
9494
},
95-
false,
96-
this
95+
false
9796
)
9897
// Merge renamed elements
9998
_.extend(submittedValue, renamedElements)
@@ -155,7 +154,7 @@ function validateCollectionValues(context, collection, validationRules) {
155154
}
156155

157156
var notSupported = ['len', 'notNull', 'isNull', 'notEmpty']
158-
var validatorFunctionKeys = _.difference(_.functions(validator), notSupported)
157+
var validatorFunctionKeys = _.difference(_.functionsIn(validator), notSupported)
159158

160159
_.each(validatorFunctionKeys, function (element, index, array) {
161160
if (!_.has(validators, element)) {

package-lock.json

Lines changed: 10 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"node": ">= 8"
3939
},
4040
"dependencies": {
41-
"lodash": "3.10.x",
41+
"lodash": "^4.17.21",
4242
"validator": "3.22.x"
4343
},
4444
"peerDependencies": {

0 commit comments

Comments
 (0)