Files
sendico/api/pkg/model/demorequest.go
Stephan D 717dafc673
Some checks failed
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
better message formatting
2025-11-19 13:54:25 +01:00

54 lines
1.6 KiB
Go

package model
import (
"strings"
"github.com/tech/sendico/pkg/merrors"
)
// DemoRequest represents a request submitted from the marketing site to request a demo.
type DemoRequest struct {
Name string `json:"name"`
OrganizationName string `json:"organizationName"`
Phone string `json:"phone"`
WorkEmail string `json:"workEmail"`
PayoutVolume string `json:"payoutVolume"`
Comment string `json:"comment,omitempty"`
}
// Normalize trims whitespace from all string fields.
func (dr *DemoRequest) Normalize() {
if dr == nil {
return
}
dr.Name = strings.TrimSpace(dr.Name)
dr.OrganizationName = strings.TrimSpace(dr.OrganizationName)
dr.Phone = strings.TrimSpace(dr.Phone)
dr.WorkEmail = strings.TrimSpace(dr.WorkEmail)
dr.PayoutVolume = strings.TrimSpace(dr.PayoutVolume)
dr.Comment = strings.TrimSpace(dr.Comment)
}
// Validate ensures that all required fields are present.
func (dr *DemoRequest) Validate() error {
if dr == nil {
return merrors.InvalidArgument("request payload is empty", "request")
}
if dr.Name == "" {
return merrors.InvalidArgument("name must not be empty", "request.name")
}
if dr.OrganizationName == "" {
return merrors.InvalidArgument("organization name must not be empty", "request.organizationName")
}
if dr.Phone == "" {
return merrors.InvalidArgument("phone must not be empty", "request.phone")
}
if dr.WorkEmail == "" {
return merrors.InvalidArgument("work email must not be empty", "request.workEmail")
}
if dr.PayoutVolume == "" {
return merrors.InvalidArgument("payout volume must not be empty", "request.payoutVolume")
}
return nil
}