validators

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDetectionIndex

func BuildDetectionIndex(configs []ProviderConfig) ([]PrefixEntry, []PatternEntry)

func DetectProviderFromIndex

func DetectProviderFromIndex(key string, prefixes []PrefixEntry, patterns []PatternEntry, manualCategory string) string

func InitValidators

func InitValidators(proxy string, timeout int) (map[string]Validator, error)

Types

type Detector

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

func NewDetector

func NewDetector() *Detector

func NewDetectorFromConfigs

func NewDetectorFromConfigs(configs []ProviderConfig) *Detector

func (*Detector) DetectProvider

func (d *Detector) DetectProvider(apiKey string, manualCategory string) string

type GenericValidator

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

func NewGenericValidator

func NewGenericValidator(cfg ProviderConfig, proxy string, timeout int) (*GenericValidator, error)

func NewGenericValidatorWithClient

func NewGenericValidatorWithClient(cfg ProviderConfig, httpClient *http.Client) *GenericValidator

func (*GenericValidator) KeyPatterns

func (v *GenericValidator) KeyPatterns() []string

func (*GenericValidator) Name

func (v *GenericValidator) Name() string

func (*GenericValidator) Validate

func (v *GenericValidator) Validate(ctx context.Context, apiKey string) (*models.ValidationResult, error)

type MetadataConfig

type MetadataConfig struct {
	URL         string            `yaml:"url"`
	Method      string            `yaml:"method"`
	Auth        string            `yaml:"auth"`
	Headers     map[string]string `yaml:"headers"`
	BalancePath string            `yaml:"balance_path"`
	Extract     string            `yaml:"extract"`
	StoreAs     string            `yaml:"store_as"`
}

type MetadataFromValidation

type MetadataFromValidation struct {
	BalancePath         string `yaml:"balance_path"`
	BalanceSubtractPath string `yaml:"balance_subtract_path"`
	NamePath            string `yaml:"name_path"`
	NameFallbackPath    string `yaml:"name_fallback_path"`
	EmailPath           string `yaml:"email_path"`
	QuotaPath           string `yaml:"quota_path"`
	CreditsPath         string `yaml:"credits_path"`
	VIPLevelPath        string `yaml:"vip_level_path"`
	TeamNamePath        string `yaml:"team_name_path"`
	UsernamePath        string `yaml:"username_path"`
}

type PatternEntry

type PatternEntry struct {
	Regex    *regexp.Regexp
	Provider string
	Category string
}

type PrefixEntry

type PrefixEntry struct {
	Prefix   string
	Provider string
	Category string
}

type ProviderConfig

type ProviderConfig struct {
	Name                   string                  `yaml:"name"`
	Category               string                  `yaml:"category"`
	KeyPrefixes            []string                `yaml:"key_prefixes"`
	KeyPatterns            []string                `yaml:"key_patterns"`
	Validation             ValidationConfig        `yaml:"validation"`
	Metadata               []MetadataConfig        `yaml:"metadata"`
	MetadataFromValidation *MetadataFromValidation `yaml:"metadata_from_validation"`
}

func InitValidatorsWithConfigs

func InitValidatorsWithConfigs(proxy string, timeout int) (map[string]Validator, []ProviderConfig, error)

func LoadProviderConfigs

func LoadProviderConfigs() ([]ProviderConfig, error)

type ProviderInfo

type ProviderInfo struct {
	Name        string
	Category    string
	KeyPrefixes []string
}

func GetAllProviders

func GetAllProviders() ([]ProviderInfo, error)

type ValidationConfig

type ValidationConfig struct {
	Method  string            `yaml:"method"`
	URL     string            `yaml:"url"`
	Auth    string            `yaml:"auth"`
	Headers map[string]string `yaml:"headers"`
	Body    string            `yaml:"body"`
}

type Validator

type Validator interface {
	Name() string
	KeyPatterns() []string
	Validate(ctx context.Context, apiKey string) (*models.ValidationResult, error)
}

Jump to

Keyboard shortcuts

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