var Joi = require('joi');
var Promise = require('bluebird');

exports.runnerConfig = function(value) {
  var schema = Joi.object().keys({
    apiKey: Joi.string().required(),
    projectRepo: Joi.string().max(100).required(),
    build: Joi.string().max(40),
    branch: Joi.string().max(100),
    resolution: Joi.string().regex(/^[0-9]{3,4}x[0-9]{3,4}$/, 'resolution'),
    ignore: Joi.string(),
    includeRules: Joi.array().min(0).items(
      Joi.string(),
      Joi.object().type(RegExp)
    ),
    excludeRules: Joi.array().min(0).items(
      Joi.string(),
      Joi.object().type(RegExp)
    ),
    states: Joi.array().min(0).items(
      Joi.object().keys({
        url: Joi.string().uri().required(),
        name: Joi.string().max(100).required()
      })
    ).required(),
    tunnel: Joi.object().keys({
      host: Joi.string().required(),
      gzip: Joi.boolean()
    }),
    diffOptions: Joi.object().keys({
      structure: Joi.boolean(),
      layout: Joi.boolean(),
      style: Joi.boolean(),
      content: Joi.boolean()
    })
  }).required();
  var validator = Promise.promisify(Joi.validate);
  return validator(value, schema);
};

@@ -1149,8 +1149,1115 @@
 ma);%0A%7D;%0A
+%0Aexports.steps = function(value) %7B%0A  var schema = Joi.array().min(0).items(%0A    Joi.object().keys(%7B%0A      type: Joi.string().valid('saveScreenshot').required(),%0A      name: Joi.string().required()%0A    %7D),%0A    Joi.object().keys(%7B%0A      type: Joi.string().valid(%5B'clickElement', 'moveTo', 'ignoreElements', 'waitForElementPresent'%5D).required(),%0A      locator: Joi.object().keys(%7B%0A        type: Joi.string().valid('css selector').required(),%0A        value: Joi.string().required()%0A      %7D)%0A    %7D),%0A    Joi.object().keys(%7B%0A      type: Joi.string().valid('setElementText').required(),%0A      locator: Joi.object().keys(%7B%0A        type: Joi.string().valid('css selector').required(),%0A        value: Joi.string().required()%0A      %7D),%0A      text: Joi.string().required()%0A    %7D),%0A    Joi.object().keys(%7B%0A      type: Joi.string().valid('executeScript').required(),%0A      code: Joi.string().required(),%0A      isAsync: Joi.boolean()%0A    %7D),%0A    Joi.object().keys(%7B%0A      type: Joi.string().valid('pause').required(),%0A      waitTime: Joi.number().required()%0A    %7D)%0A  ).required();%0A  return Joi.validate(value, schema);%0A%7D;%0A

add validator for steps