Initial import
This commit is contained in:
9
etc/servers/work-server/src/lib/identifier.ts
Executable file
9
etc/servers/work-server/src/lib/identifier.ts
Executable file
@@ -0,0 +1,9 @@
|
||||
const IDENTIFIER_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
||||
|
||||
export function assertIdentifier(value: string, label = 'identifier') {
|
||||
if (!IDENTIFIER_PATTERN.test(value)) {
|
||||
throw new Error(`Invalid ${label}: ${value}`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
Reference in New Issue
Block a user