* Validates the parameters for the tool * @param params Parameters to validate * @returns An error message string if invalid, null otherwise
(params: LSToolParams)
| 316 | * @returns An error message string if invalid, null otherwise |
| 317 | */ |
| 318 | override validateToolParams(params: LSToolParams): string | null { |
| 319 | const errors = SchemaValidator.validate( |
| 320 | this.schema.parametersJsonSchema, |
| 321 | params, |
| 322 | ); |
| 323 | if (errors) { |
| 324 | return errors; |
| 325 | } |
| 326 | if (!path.isAbsolute(params.path)) { |
| 327 | return `Path must be absolute: ${params.path}`; |
| 328 | } |
| 329 | |
| 330 | const workspaceContext = this.config.getWorkspaceContext(); |
| 331 | if (!workspaceContext.isPathWithinWorkspace(params.path)) { |
| 332 | const directories = workspaceContext.getDirectories(); |
| 333 | return `Path must be within one of the workspace directories: ${directories.join( |
| 334 | ', ', |
| 335 | )}`; |
| 336 | } |
| 337 | return null; |
| 338 | } |
| 339 | |
| 340 | protected createInvocation( |
| 341 | params: LSToolParams, |
no test coverage detected