code: function (val) {
          return val &&
              typeof val === 'object' &&
              !(val instanceof Date) &&
              !(val instanceof ObjectId) &&
              (!Array.isArray(val) || val.length > 0) &&
              !(val instanceof Buffer);
      }
docs: CODE BETWEEN THESE COMMENT LINES WAS ADAPTED FROM THE MONGOOSE CODEBASE