MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / validateHook

Function validateHook

internal/hooks/manager.go:363–377  ·  view source on GitHub ↗

validateHook checks if a hook configuration is valid. It ensures the URL and type are set correctly, and sets default values for timeout and retry count if missing. Parameters: - hook: The hook to validate. Returns: - error: An error if validation fails.

(hook *Hook)

Source from the content-addressed store, hash-verified

361// Returns:
362// - error: An error if validation fails.
363func validateHook(hook *Hook) error {
364 if hook.URL == "" {
365 return fmt.Errorf("hook URL is required")
366 }
367 if hook.Type != PreTransaction && hook.Type != PostTransaction {
368 return fmt.Errorf("invalid hook type: %s", hook.Type)
369 }
370 if hook.Timeout <= 0 {
371 hook.Timeout = 30 // Default timeout
372 }
373 if hook.RetryCount < 0 {
374 hook.RetryCount = 3 // Default retry count
375 }
376 return nil
377}
378
379// getTypeKey returns the Redis key for a specific hook type set.
380//

Callers 1

RegisterHookMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected