bybit.go.api/handlers/params_verification.go

24 lines
456 B
Go
Raw Permalink Normal View History

2023-11-05 23:35:56 +02:00
package handlers
import (
"fmt"
)
func ValidateParams(params map[string]interface{}) error {
seenKeys := make(map[string]bool)
for key, value := range params {
if key == "" {
return fmt.Errorf("empty key found in parameters")
}
if seenKeys[key] {
return fmt.Errorf("duplicate key found in parameters: %s", key)
}
if value == nil {
return fmt.Errorf("parameter for key '%s' is nil", key)
}
seenKeys[key] = true
}
return nil
}