package domain import ( "fmt" "github.com/jackc/pgx/v5/pgtype" ) type EventSource string const ( EVENT_SOURCE_BET365 EventSource = "b365api" EVENT_SOURCE_BWIN EventSource = "bwin" EVENT_SOURCE_BETFAIR EventSource = "bfair" EVENT_SOURCE_1XBET EventSource = "1xbet" EVENT_SOURCE_ENET EventSource = "enetpulse" ) // --- EventSource Validation --- func (s EventSource) IsValid() bool { switch s { case EVENT_SOURCE_BET365, EVENT_SOURCE_BWIN, EVENT_SOURCE_BETFAIR, EVENT_SOURCE_1XBET, EVENT_SOURCE_ENET: return true default: return false } } func ParseEventSource(val string) (EventSource, error) { s := EventSource(val) if !s.IsValid() { return "", fmt.Errorf("invalid EventSource: %q", val) } return s, nil } type ValidEventSource struct { Value EventSource Valid bool } func (v ValidEventSource) ToPG() pgtype.Text { return pgtype.Text{ String: string(v.Value), Valid: v.Valid, } }