const check = require('validator').check
const db = require('../lib/db');

const Issuers = db.table('issuers', {
  fields: [
    'id',
    'slug',
    'name',
    'url',
    'description',
    'email',
    'imageId'
  ],
});

Issuers.validateRow = function (row) {
  const errors = []
  this.fields.forEach(function (field) {
    try {
      const validator = validation[field] || noop
      validator(row[field])
    }
    catch(e) {
      e.field = field
      errors.push(e)
    }
  })
  return errors
}

const validation = {
  id: function (id) {
    if (typeof id == 'undefined') return;
    check(id).isInt();
  },
  slug: function (slug) {
    check(slug).len(1, 50);
  },
  name: function (name) {
    check(name).len(1, 50);
  },
  url: function (url) {
    check(url).isUrl();
  },
  description: function (desc) {
    check(desc).len(0, 255);
  },
  email: function (email) {
    if (typeof email == 'undefined') return;
    check(email).isEmail();
  },
}

function noop() {}

exports = module.exports = Issuers;

@@ -264,27 +264,14 @@
 %7B%0A  
-const errors = %5B%5D%0A 
+return
  thi
@@ -283,15 +283,14 @@
 lds.
-forEach
+reduce
 (fun
@@ -296,16 +296,24 @@
 nction (
+errors, 
 field) %7B
@@ -477,11 +477,8 @@
 %7D%0A  
-%7D)%0A
   re
@@ -489,16 +489,25 @@
  errors%0A
+  %7D, %5B%5D)%0A
 %7D%0A%0Aconst

Use a reduce instead of forEach