validate

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxProviderNameLength is the maximum length for custom provider names.
	// Most provider names are short identifiers (e.g., "anthropic", "openai").
	MaxProviderNameLength = 50

	// MaxModelNameLength is the maximum length for model names.
	// Most LLM model names are reasonable length (e.g., "claude-3-opus-20240229").
	MaxModelNameLength = 100
)

Validation limits for provider and model names.

Variables

View Source
var (
	ErrInvalidAPIKey = &ValidationError{msg: "API key validation failed"}
	ErrInvalidURL    = &ValidationError{msg: "invalid URL: must be HTTPS and not use blocked hosts"}
)

Functions

func NewValidationError

func NewValidationError(msg string) error

func ValidateAPIKey

func ValidateAPIKey(key string, providerName string) error

func ValidateCrossProviderConfig added in v1.10.0

func ValidateCrossProviderConfig(cfg *config.Config) error

validateCrossProviderConfig validates configuration across all providers to detect conflicts.

This function checks for environment variable collisions where multiple providers attempt to set the same environment variable with different values. Collisions with identical values are allowed (idempotent).

func ValidateProviderModel added in v1.10.0

func ValidateProviderModel(providerName, modelName string) error

ValidateProviderModel validates a model name against provider capabilities. For built-in providers with default models, this ensures the model is reasonable. Returns an error if the model name is invalid.

func ValidateURL

func ValidateURL(rawURL string, providerName string) error

Types

type KeyFormat added in v1.7.0

type KeyFormat struct {
	MinLength int
	Prefix    string
	Pattern   string
}

type ValidationError

type ValidationError struct {
	// contains filtered or unexported fields
}

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL