lib/modules/queryBuilder.js
function validate (resource, doc, doValidate) {
  return new Promise((resolve, reject) => {
    if (doValidate !== true) {
      return resolve();
    }
    if (resource.validate(doc)) {
      return resolve();
    } else {
      debug('model have %d error(s)', resource.validate.errors.length);
      return reject(resource.validate.errors);
    }
  });
}
function validate (resource, doc, doValidate) {
  return new Promise((resolve, reject) => {
    if (doValidate !== true) {
      return resolve();
    }
    if (resource.validate(doc)) {
      return resolve();
    } else {
      debug('model have %d error(s)', resource.validate.errors.length);
      return reject(resource.validate.errors);
    }
  });
}
Validate a document against its resource
@param {object} resource
@param {object} doc
@param {boolean} doValidate
@returns {Promise}