mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 20:31:37 -05:00
Refactor utilities to utils for consistency
This commit is contained in:
34
webview-ui/src/utils/validate.ts
Normal file
34
webview-ui/src/utils/validate.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { ApiConfiguration } from "@shared/api"
|
||||
|
||||
export function validateApiConfiguration(apiConfiguration?: ApiConfiguration): string | undefined {
|
||||
if (apiConfiguration) {
|
||||
switch (apiConfiguration.apiProvider) {
|
||||
case "anthropic":
|
||||
if (!apiConfiguration.apiKey) {
|
||||
return "You must provide a valid API key or choose a different provider."
|
||||
}
|
||||
break
|
||||
case "bedrock":
|
||||
if (!apiConfiguration.awsAccessKey || !apiConfiguration.awsSecretKey || !apiConfiguration.awsRegion) {
|
||||
return "You must provide a valid AWS access key, secret key, and region."
|
||||
}
|
||||
break
|
||||
case "openrouter":
|
||||
if (!apiConfiguration.openRouterApiKey) {
|
||||
return "You must provide a valid API key or choose a different provider."
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
export function validateMaxRequestsPerTask(maxRequestsPerTask?: string): string | undefined {
|
||||
if (maxRequestsPerTask && maxRequestsPerTask.trim()) {
|
||||
const num = Number(maxRequestsPerTask)
|
||||
if (isNaN(num) || num < 3 || num > 100) {
|
||||
return "Maximum requests must be between 3 and 100"
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
Reference in New Issue
Block a user