MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / validateOptionalPath

Method validateOptionalPath

src/mcp/tools.ts:2825–2839  ·  view source on GitHub ↗

* Validate an optional path-like string input. Returns the value if * valid (or undefined), or a ToolResult with the error.

(
    value: unknown,
    name: string
  )

Source from the content-addressed store, hash-verified

2823 * valid (or undefined), or a ToolResult with the error.
2824 */
2825 private validateOptionalPath(
2826 value: unknown,
2827 name: string
2828 ): string | undefined | ToolResult {
2829 if (value === undefined || value === null) return undefined;
2830 if (typeof value !== 'string') {
2831 return this.errorResult(`${name} must be a string`);
2832 }
2833 if (value.length > MAX_PATH_LENGTH) {
2834 return this.errorResult(
2835 `${name} exceeds maximum length of ${MAX_PATH_LENGTH} characters (got ${value.length})`
2836 );
2837 }
2838 return value;
2839 }
2840
2841 /**
2842 * Cached git worktree/index mismatch for a tool call's effective project.

Callers 1

executeMethod · 0.95

Calls 1

errorResultMethod · 0.95

Tested by

no test coverage detected