Files
30b884945c feat: Column Connector for Payments (#351)
* Update PR with latest updates from `main`, fix conflicts

* Update PR with changes from main

---------

Co-authored-by: gitstart_bot <[email protected]>
2025-04-10 14:44:38 +02:00

25 lines
611 B
Go

package column
import (
"encoding/json"
"fmt"
"github.com/formancehq/payments/internal/models"
"github.com/go-playground/validator/v10"
)
type Config struct {
APIKey string `json:"apiKey" validate:"required"`
Endpoint string `json:"endpoint" validate:"required"`
}
func unmarshalAndValidateConfig(payload json.RawMessage) (Config, error) {
var config Config
if err := json.Unmarshal(payload, &config); err != nil {
return Config{}, fmt.Errorf("%w: %w", err, models.ErrInvalidConfig)
}
validate := validator.New(validator.WithRequiredStructEnabled())
return config, validate.Struct(config)
}