Refactor config package validation
This commit is contained in:
@@ -125,7 +125,6 @@ type JobConfig struct {
|
||||
// Timeout limits the job execution time (e.g., "10m").
|
||||
Timeout time.Duration `yaml:"timeout,omitempty"`
|
||||
// UserId identifies the user that owns conversations created by this job.
|
||||
// It is assigned by the service until jobs are stored in the database.
|
||||
UserId string `yaml:"user_id,omitempty"`
|
||||
}
|
||||
|
||||
@@ -145,6 +144,9 @@ func (cfg JobConfig) Validate() error {
|
||||
if cfg.Timeout < 0 {
|
||||
return fmt.Errorf("invalid timeout %v: must not be negative", cfg.Timeout)
|
||||
}
|
||||
if cfg.UserId == "" {
|
||||
return fmt.Errorf("missing user_id")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user