in tasks/Node/src/modules/task-utils/resourceutil.ts [111:127]
export function testVmName(vmName: string, maxNameLength: number = 15): boolean {
if (!vmName) {
throw `Invalid VM name '${vmName}'. Name must be specified.`;
}
if (vmName.length > maxNameLength) {
throw `Invalid VM name '${vmName}'. Name must be between 1 and ${maxNameLength} characters.`;
}
// TODO: Get latest Regex from DTL UI code.
const regex = new RegExp('^(?=.*[a-zA-Z/-]+)[0-9a-zA-Z/-]*$');
if (!regex.test(vmName)) {
throw `Invalid VM name '${vmName}'. Name cannot contain any spaces or special characters. The name may contain letters, numbers, or '-'. However, it must begin and end with a letter or number, and cannot be all numbers.`;
}
return true;
}