mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
* Update PR with latest updates from `main`, fix conflicts * Update PR with changes from main --------- Co-authored-by: gitstart_bot <[email protected]>
25 lines
611 B
Go
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)
|
|
}
|