Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config represents the top-level configuration loaded from challenges.json. This structure is parsed from JSON and validated during application startup.
type ConfigLoader ¶
type ConfigLoader struct {
// contains filtered or unexported fields
}
ConfigLoader loads and validates challenge configuration from a JSON file. It performs file reading, JSON parsing, and comprehensive validation.
func NewConfigLoader ¶
func NewConfigLoader(configPath string, logger *slog.Logger) *ConfigLoader
NewConfigLoader creates a new ConfigLoader instance.
Parameters:
- configPath: Path to the challenges.json file
- logger: Structured logger for operational logging
func (*ConfigLoader) LoadConfig ¶
func (l *ConfigLoader) LoadConfig() (*Config, error)
LoadConfig loads the configuration file and returns a validated Config. This method performs three steps: 1. Read the config file from disk 2. Parse JSON into Config struct 3. Validate all business rules
If any step fails, returns an error and the application should exit. This is a "fail fast" operation - invalid config prevents startup.
Returns:
- *Config: Valid configuration ready for use
- error: Descriptive error if loading or validation fails
type Validator ¶
type Validator struct{}
Validator validates challenge configuration files. It ensures all business rules are met before the application starts.
func (*Validator) Validate ¶
Validate performs comprehensive validation of the configuration. It checks for: - At least one challenge exists - All challenge IDs are unique - All goal IDs are globally unique - All prerequisites reference valid goals - All requirements and rewards are valid
Returns an error describing the first validation failure encountered.