Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//build mongoose error
if (!_.isEmpty(path)) {
const errors = {};
_.forEach(path, function (pathName) {
const props = {
type: 'unique',
path: pathName,
value: _.get(values, pathName),
message: 'Path `{PATH}` ({VALUE}) is not unique.',
reason: error.message
};
errors[pathName] = new mongoose.Error.ValidatorError(props);
});
error = new mongoose.Error.ValidationError();
error.errors = errors;
}
next(error);
};
_.forEach(path, function (pathName) {
const props = {
type: 'unique',
path: pathName,
value: _.get(values, pathName),
message: 'Path `{PATH}` ({VALUE}) is not unique.',
reason: error.message
};
errors[pathName] = new mongoose.Error.ValidatorError(props);
});