mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
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
43 lines
856 B
Go
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
|
|
}
|