message: fail create/update kata if validate function is wrong
diff: -import {Body, Post, JsonController, UseBefore, Put, Param, Authorized} from 'routing-controllers';
  +import {Body, Post, JsonController, UseBefore, Put, Param, Authorized, BadRequestError} from 'routing-controllers';
  import passportJwtMiddleware from '../security/passportJwtMiddleware';
  import {UnitBaseController} from './UnitBaseController';
  import {CodeKataUnit} from '../models/units/CodeKataUnit';
  @@ -15,6 +15,7 @@ export class CodeKataUnitController extends UnitBaseController {
  this.checkPostParam(data);
  data.model = this.splitCodeAreas(data.model);
  + this.validateKata(data.model);
  return new CodeKataUnit(data.model).save()
  .then((savedCodeKataUnit) => {
  @@ -26,10 +27,28 @@ export class CodeKataUnitController extends UnitBaseController {
  @Put('/:id')
  updateCodeKataUnit(@Param('id') id: string, @Body() unit: ICodeKataUnit) {
  unit = this.splitCodeAreas(unit);
  + this.validateKata(unit);
  return CodeKataUnit.findByIdAndUpdate(id, unit, {new: true})
  .then(u => u.toObject());
  }
  + private validateKata(unit: ICodeKataUnit) {
  + if (!unit.definition || !unit.code || !unit.test) {
  + throw new BadRequestError('A Kata must at least contain 3 areas');
  + }
  +
  + console.log(unit);
  + if (!unit.test.match(new RegExp('function(.|\t)*validate\\(\\)(.|\n|\t)*{(.|\n|\t)*}', 'gmi'))) {
  + throw new BadRequestError('The test section must contain a validate function');
  + }
  + if (!unit.test.match(new RegExp('function(.|\t)*validate\\(\\)(.|\n|\t)*{(.|\n|\t)*return(.|\n|\t)*}', 'gmi'))) {
  + throw new BadRequestError('The validate function must return something');
  + }
  + if (!unit.test.match(new RegExp('validate\\(\\);', 'gmi'))) {
  + throw new BadRequestError('The test section must call the validate function');
  + }
  + }
  +
  private splitCodeAreas(unit: ICodeKataUnit): ICodeKataUnit {
  if (unit.definition !== undefined || unit.test !== undefined || unit.code === undefined) {
  return unit;
  