(arn: string, region?: string)
| 215 | * @returns An object with validation results: { isValid, arnRegion, errorMessage } |
| 216 | */ |
| 217 | export function validateBedrockArn(arn: string, region?: string) { |
| 218 | // Try to extract region from ARN for region mismatch warning. |
| 219 | // This is a permissive regex that attempts to find the region component |
| 220 | // without enforcing strict ARN format validation. |
| 221 | const regionMatch = arn.match(/^arn:[^:]+:[^:]+:([^:]+):/) |
| 222 | const arnRegion = regionMatch?.[1] |
| 223 | |
| 224 | // Check if region in ARN matches provided region (if specified). |
| 225 | if (region && arnRegion && arnRegion !== region) { |
| 226 | return { |
| 227 | isValid: true, |
| 228 | arnRegion, |
| 229 | errorMessage: i18next.t("settings:validation.arn.regionMismatch", { arnRegion, region }), |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | // ARN is always considered valid - trust the user to enter valid ARNs. |
| 234 | return { isValid: true, arnRegion, errorMessage: undefined } |
| 235 | } |
| 236 | |
| 237 | function validateDynamicProviderModelId( |
| 238 | apiConfiguration: ProviderSettings, |
no outgoing calls
no test coverage detected