MCPcopy Create free account
hub / github.com/bytebase/dbhub / validateParameters

Function validateParameters

src/utils/parameter-mapper.ts:153–170  ·  view source on GitHub ↗
(
  statement: string,
  parameters: ParameterConfig[] | undefined,
  connectorType: ConnectorType
)

Source from the content-addressed store, hash-verified

151 * @throws Error if validation fails
152 */
153export function validateParameters(
154 statement: string,
155 parameters: ParameterConfig[] | undefined,
156 connectorType: ConnectorType
157): void {
158 // Validate parameter style matches connector
159 validateParameterStyle(statement, connectorType);
160
161 const paramCount = countParameters(statement);
162 const definedCount = parameters?.length || 0;
163
164 if (paramCount !== definedCount) {
165 throw new Error(
166 `Parameter count mismatch: SQL statement has ${paramCount} parameter(s), ` +
167 `but ${definedCount} parameter(s) defined in tool configuration.`
168 );
169 }
170}
171
172/**
173 * Map user-provided arguments to an array suitable for connector execution

Callers 2

validateCustomToolMethod · 0.85

Calls 2

validateParameterStyleFunction · 0.85
countParametersFunction · 0.85

Tested by

no test coverage detected