Skip to content

Commit

Permalink
Merge pull request #15 from dudi938/master
Browse files Browse the repository at this point in the history
fix the duplicate validate implemntion
  • Loading branch information
grawcho committed Jul 18, 2017
2 parents 1ab193c + 0e19e84 commit 51e307f
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions app/exec/build/tasks/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,51 +47,6 @@ export class BuildTaskValidate extends tasksBase.BuildTaskBase<agentContracts.Ta
});
}



public validate(jsonFilePath) {
var taskJson;
try {
taskJson = require(jsonFilePath);
}
catch (jsonError) {
console.log('jsonError = ' + jsonError)
trace.debug('Invalid task json: %s', jsonError);
throw new Error("Invalid task json: " + jsonError);
}

this.validateTask(jsonFilePath, taskJson);
}


/*
* Validates a parsed json file describing a build task
* @param taskPath the path to the original json file
* @param taskData the parsed json file
* @return list of issues with the json file
*/
public validateTask(taskPath: string, taskData: any): string[] {
var vn = (taskData.name || taskPath);
var issues: string[] = [];

if (!taskData.id || !check.isUUID(taskData.id)) {
issues.push(vn + ': id is a required guid');
}

if (!taskData.name || !check.isAlphanumeric(taskData.name)) {
issues.push(vn + ': name is a required alphanumeric string');
}

if (!taskData.friendlyName || !check.isLength(taskData.friendlyName, 1, 40)) {
issues.push(vn + ': friendlyName is a required string <= 40 chars');
}

if (!taskData.instanceNameFormat) {
issues.push(vn + ': instanceNameFormat is required');
}
return issues;
}

public friendlyOutput(data: agentContracts.TaskDefinition): void {
trace.println();
trace.success('Task at %s Validated successfully!', data.sourceLocation);
Expand Down

0 comments on commit 51e307f

Please sign in to comment.