Some checks failed
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline is pending
ci/woodpecker/push/ledger Pipeline is pending
ci/woodpecker/push/nats Pipeline is pending
ci/woodpecker/push/notification Pipeline is pending
ci/woodpecker/push/payments_orchestrator Pipeline is pending
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/frontend Pipeline failed
ci/woodpecker/push/fx_ingestor Pipeline failed
ci/woodpecker/push/bump_version unknown status
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package model
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/tech/sendico/pkg/merrors"
|
|
)
|
|
|
|
// ContactRequest represents a contact form submission from the marketing site.
|
|
type ContactRequest struct {
|
|
Name string `json:"name"`
|
|
Email string `json:"email"`
|
|
Phone string `json:"phone"`
|
|
Company string `json:"company"`
|
|
Topic string `json:"topic"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// Normalize trims whitespace from all string fields.
|
|
func (cr *ContactRequest) Normalize() {
|
|
if cr == nil {
|
|
return
|
|
}
|
|
cr.Name = strings.TrimSpace(cr.Name)
|
|
cr.Email = strings.TrimSpace(cr.Email)
|
|
cr.Phone = strings.TrimSpace(cr.Phone)
|
|
cr.Company = strings.TrimSpace(cr.Company)
|
|
cr.Topic = strings.TrimSpace(cr.Topic)
|
|
cr.Message = strings.TrimSpace(cr.Message)
|
|
}
|
|
|
|
// Validate ensures required contact request fields are present.
|
|
func (cr *ContactRequest) Validate() error {
|
|
if cr == nil {
|
|
return merrors.InvalidArgument("request payload is empty", "request")
|
|
}
|
|
if (cr.Email == "") && (cr.Phone == "") {
|
|
return merrors.InvalidArgument("email or phone must not be empty", "request.email", "request.phone")
|
|
}
|
|
return nil
|
|
}
|