MCPcopy Create free account
hub / github.com/subquery/subql / validDbSchemaName

Function validDbSchemaName

packages/node-core/src/configure/configure.module.ts:20–39  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

18
19// Check if a subquery name is a valid schema name
20export function validDbSchemaName(name: string): boolean {
21 if (name.length === 0) {
22 return false;
23 } else {
24 name = name.toLowerCase();
25 const regexp = new RegExp('^[a-zA-Z_][a-zA-Z0-9_\\-\\/]{0,62}$');
26 const flag0 = !name.startsWith('pg_'); // Reserved identifier
27 const flag1 = regexp.test(name); // <= Valid characters, less than 63 bytes
28 if (!flag0) {
29 logger.error(`Invalid schema name '${name}', schema name must not be prefixed with 'pg_'`);
30 }
31 if (!flag1) {
32 logger.error(
33 `Invalid schema name '${name}', schema name must start with a letter or underscore,
34 be less than 63 bytes and must contain only valid alphanumeric characters (can include characters '_-/')`
35 );
36 }
37 return flag0 && flag1;
38 }
39}
40
41// Cant seem to use the inferred types, strings arent converted to unions
42type Args = Record<string, any>; //ReturnType<typeof yargsBuilder>['argv']

Callers 2

registerAppFunction · 0.85

Calls 1

errorMethod · 0.45

Tested by

no test coverage detected