11 lines
260 B
TypeScript
11 lines
260 B
TypeScript
function validate_name (name: string): string {
|
|
const new_name = name
|
|
.replace (/[^a-z0-9]/giu, '')
|
|
.replace (/^[0-9]+/iu, '');
|
|
if (new_name === '')
|
|
throw new Error (`invalid node name ${name}`);
|
|
return new_name;
|
|
}
|
|
|
|
export { validate_name };
|