Files
zeekay 1943f1c093 Hanzo Commerce
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans,
usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0.

Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
2026-09-23 21:52:16 -07:00

43 lines
856 B
Go

package types
import (
"fmt"
"net/http"
"github.com/mholt/binding"
)
type MediaType string
const (
MediaVideo MediaType = "video"
MediaImage = "image"
MediaLiveStream = "livestream"
MediaWebGL = "webgl"
MediaAudio = "audio"
MediaEmbed = "embed"
)
type Media struct {
Type MediaType `json:"type"`
Alt string `json:"alt"`
Url string `json:"url"`
X int `json:"x"`
Y int `json:"y"`
}
func (i Media) Dimensions() string {
return fmt.Sprintf("%dx%d", i.X, i.Y)
}
func (i Media) Validate(req *http.Request, errs binding.Errors) binding.Errors {
if i.Url == "" {
errs = append(errs, binding.Error{
FieldNames: []string{"Url"},
Classification: "InputError",
Message: "Image does not have a URL",
})
}
return errs
}