lib/defaultCommandHandler.js
function (aggregate, cmd) {
    if (!aggregate || !_.isObject(aggregate)) {
      var err = new Error('Please pass a valid aggregate!');
      debug(err);
      throw err;
    }
    if (!cmd || !_.isObject(cmd)) {
      var err = new Error('Please pass a valid command!');
      debug(err);
      throw err;
    }

    var reason = this.isAggregateDestroyed(aggregate, cmd);
    if (reason) {
      return reason;
    }

    if (this.aggregate.disablePersistence) return;

    reason = this.isRevisionWrong(aggregate, cmd);
    if (reason) {
      return reason;
    }
  }
function (aggregate, cmd) {
    if (!aggregate || !_.isObject(aggregate)) {
      var err = new Error('Please pass a valid aggregate!');
      debug(err);
      throw err;
    }
    if (!cmd || !_.isObject(cmd)) {
      var err = new Error('Please pass a valid command!');
      debug(err);
      throw err;
    }

    var reason = this.isAggregateDestroyed(aggregate, cmd);
    if (reason) {
      return reason;
    }

    if (this.aggregate.disablePersistence) return;

    reason = this.isRevisionWrong(aggregate, cmd);
    if (reason) {
      return reason;
    }
  }
function ( aggregate , cmd ) { if ( ! aggregate || ! _ . isObject ( aggregate ) ) { var err = new Error ( 'Please pass a valid aggregate!' ) ; debug ( err ) ; throw err ; } if ( ! cmd || ! _ . isObject ( cmd ) ) { var err = new Error ( 'Please pass a valid command!' ) ; debug ( err ) ; throw err ; } var reason = this . isAggregateDestroyed ( aggregate , cmd ) ; if ( reason ) { return reason ; } if ( this . aggregate . disablePersistence ) return ; reason = this . isRevisionWrong ( aggregate , cmd ) ; if ( reason ) { return reason ; } }
Returns an error if verification fails.
@param {AggregateModel} aggregate The passed aggregate.
@param {Object}         cmd       The command.
@returns {Error}
Returns an error if verification fails .