message: adds some structure validation for the creation of code-katas
  close # 262
diff: @@ -128,6 +128,10 @@ export class CodeKataUnitFormComponent implements OnInit {
  // refactor this to use the same as in code-kata-unit
  validate() {
  + if (!this.validateStructure) {
  + return false;
  + }
  +
  const codeToTest: string = this.model.code;
  this.logs = undefined;
  @@ -168,4 +172,22 @@ export class CodeKataUnitFormComponent implements OnInit {
  }
  }
  + // this code gets unnessessary with the Implementation of Issue #44 (all validation parts should happen on the server)
  + private validateStructure(): boolean {
  + if (!this.model.test.match(new RegExp('function(.|\t)*validate\\(\\)(.|\n|\t)*{(.|\n|\t)*}', 'gmi'))) {
  + this.snackBar.open('The test section must contain a validate function');
  + return false;
  + }
  + if (!this.model.test.match(new RegExp('function(.|\t)*validate\\(\\)(.|\n|\t)*{(.|\n|\t)*return(.|\n|\t)*}', 'gmi'))) {
  + this.snackBar.open('The validate function must return something');
  + return false;
  + }
  + if (!this.model.test.match(new RegExp('validate\\(\\);', 'gmi'))) {
  + this.snackBar.open('The test section must call the validate function');
  + return false;
  + }
  +
  + return true;
  + }
  +
  }
  