MCPcopy Index your code
hub / github.com/coder/coder / validateAIProviderBaseURL

Function validateAIProviderBaseURL

codersdk/aiproviders.go:326–343  ·  view source on GitHub ↗
(raw string)

Source from the content-addressed store, hash-verified

324}
325
326func validateAIProviderBaseURL(raw string) []ValidationError {
327 var validations []ValidationError
328 parsed, err := url.Parse(raw)
329 if err != nil || parsed.Scheme == "" || parsed.Host == "" {
330 validations = append(validations, ValidationError{
331 Field: "base_url",
332 Detail: "base_url must be an absolute URL (e.g. https://api.example.com/)",
333 })
334 return validations
335 }
336 if parsed.Scheme != "http" && parsed.Scheme != "https" {
337 validations = append(validations, ValidationError{
338 Field: "base_url",
339 Detail: fmt.Sprintf("base_url scheme must be http or https, got %q", parsed.Scheme),
340 })
341 }
342 return validations
343}
344
345// validateAIProviderAPIKeys checks that each supplied key is non-empty
346// and free of leading/trailing whitespace. An empty slice itself is

Callers 1

Calls 1

ParseMethod · 0.65

Tested by

no test coverage detected