keyvalidator

package
v0.0.1-test9 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrValidationFailed = errors.New("api key validation failed")

ErrValidationFailed marks errors where a provider rejected a supplied API key.

Functions

This section is empty.

Types

type Registry

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

Registry stores provider-specific key validators.

func DefaultRegistry

func DefaultRegistry(client *http.Client) *Registry

DefaultRegistry creates the built-in validator set.

func NewRegistry

func NewRegistry(validators map[string]Validator) *Registry

NewRegistry creates a validator registry from an explicit provider map.

func (*Registry) HasValidator

func (r *Registry) HasValidator(provider string) bool

HasValidator reports whether the registry has a validator for the provider.

func (*Registry) ValidateAPIKey

func (r *Registry) ValidateAPIKey(ctx context.Context, provider, apiKey string) error

ValidateAPIKey validates the provider key when a validator is registered. Providers without validators are treated as success.

type ValidationError

type ValidationError struct {
	Provider string
	Message  string
	Err      error
}

ValidationError is returned when a provider rejects a key during validation.

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

type Validator

type Validator interface {
	Validate(ctx context.Context, apiKey string) error
}

Validator validates a provider-specific API key.

Jump to

Keyboard shortcuts

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