Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade lodash #87

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/conditions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* The MIT License
*
* Copyright 2014 Timo Behrmann, Guillaume Chauvet.
Expand Down Expand Up @@ -28,7 +28,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 All @@ -49,4 +49,4 @@ var conditionalChecker = module.exports.conditionalChecker = function (params, v
var matches = params.matches;
return validator(matches, this.req[scope][variable]);
};
};
};
12 changes: 6 additions & 6 deletions lib/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var validators = module.exports = {
return true;
}
},
equalTo: function(key, submittedValue, myValidator) {
equalTo: function (key, submittedValue, myValidator) {
if (!_.isEqual(submittedValue, this.req[this.scope][myValidator.value])) {
return true;
}
Expand Down Expand Up @@ -89,7 +89,7 @@ var validators = module.exports = {
}
if (isDictionary.key) {
var renamedElements = {};
var keyError = _.reduce(submittedValue, function(previousError, value, key) {
var keyError = _.reduce(submittedValue, function (previousError, value, key) {
if (previousError) {
return previousError;
}
Expand All @@ -101,15 +101,15 @@ var validators = module.exports = {
}
return validateKey.error;

}, false, this);
}.bind(this), false);
// Merge renamed elements
_.extend(submittedValue, renamedElements);
if (keyError) {
return keyError;
}
}
if (isDictionary.value) {
var valueError = validateCollectionValues(this, submittedValue, isDictionary.value);
var valueError = validateCollectionValues(this, submittedValue, isDictionary.value);
if (valueError) {
return valueError;
}
Expand All @@ -135,7 +135,7 @@ var validators = module.exports = {
};

function validateCollectionValues(context, collection, validationRules) {
return _.reduce(collection, function(previousError, value, index) {
return _.reduce(collection, function (previousError, value, index) {
if (previousError) {
return previousError;
}
Expand All @@ -149,7 +149,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
Loading