All files / mongoose/lib/helpers/error combinePathErrors.js

9.09% Statements 1/11
0% Branches 0/4
0% Functions 0/1
10% Lines 1/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23            1x                                
'use strict';
 
/*!
 * ignore
 */
 
module.exports = function combinePathErrors(err) {
  const keys = Object.keys(err.errors || {});
  const len = keys.length;
  const msgs = [];
  let key;
 
  for (let i = 0; i < len; ++i) {
    key = keys[i];
    if (err === err.errors[key]) {
      continue;
    }
    msgs.push(key + ': ' + err.errors[key].message);
  }
 
  return msgs.join(', ');
};