| 90 | } |
| 91 | |
| 92 | func validateConnection(connection *models.GhCopilotConnection) errors.Error { |
| 93 | if connection == nil { |
| 94 | return errors.BadInput.New("connection is required") |
| 95 | } |
| 96 | if connection.Organization == "" && !connection.HasEnterprise() { |
| 97 | return errors.BadInput.New("either enterprise or organization is required") |
| 98 | } |
| 99 | if connection.Token == "" { |
| 100 | return errors.BadInput.New("token is required") |
| 101 | } |
| 102 | if connection.RateLimitPerHour < 0 { |
| 103 | return errors.BadInput.New("rateLimitPerHour must be non-negative") |
| 104 | } |
| 105 | return nil |
| 106 | } |