lib/classes/Service.js/Service/validate
class Service:  validate() {
    _.forEach(this.functions, (functionObj, functionName) => {
      if (!_.isArray(functionObj.events)) {
        throw new ServerlessError(`Events for "${functionName}" must be an array,` +
                          ` not an ${typeof functionObj.events}`);
      }
    });

    const provider = this.serverless.getProvider('aws');
    if (provider) {
      const stage = provider.getStage();
      this.getAllFunctions().forEach(funcName => {
        _.forEach(this.getAllEventsInFunction(funcName), event => {
          if (_.has(event, 'http') && !validAPIGatewayStageNamePattern.test(stage)) {
            throw new this.serverless.classes.Error([
              `Invalid stage name ${stage}:`,
              'it should contains only [-_a-zA-Z0-9] for AWS provider if http event are present',
              'according to API Gateway limitation.',
            ].join(' '));
          }
        });
      });
    }

    return this;
  }