domain

package
v0.0.0-...-1b8390b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxProdCategoryLength = 32
	MaxProdNameLength     = 256
	MaxProdDescLength     = 2048

	MinPrice = 0.01
	MaxPrice = 128000
)
View Source
const (
	MaxQueryLength = 256
)

Variables

View Source
var (
	ErrInvalidArgument = errors.New("invalid argument")

	ErrProductNotFound      = errors.New("product not found")
	ErrProductAlreadyExists = errors.New("product already exists")
)

Functions

func ValidateCategory

func ValidateCategory(category string) bool

func ValidateDescription

func ValidateDescription(desc string) bool

func ValidateName

func ValidateName(name string) bool

func ValidatePrice

func ValidatePrice(price float64) bool

Types

type Product

type Product struct {
	ID        uuid.UUID
	Name      string
	Desc      string
	Category  string
	Price     float64
	IsActive  bool
	CreatedAt time.Time
	UpdatedAt time.Time
}

func NewProduct

func NewProduct(id uuid.UUID, name, description, category string, price float64) *Product

func NewValidatedProduct

func NewValidatedProduct(id uuid.UUID, name, description, category string, price float64) (*Product, error)

func (*Product) Update

func (c *Product) Update(name, description, category string, isActive bool, price float64)

func (*Product) Validate

func (c *Product) Validate() error

type SearchOptions

type SearchOptions struct {
	Query    *string
	Category *string
	MinPrice *float64
	MaxPrice *float64
}

func NewSearchOptions

func NewSearchOptions(query *string, category *string, minPrice *float64, maxPrice *float64) SearchOptions

func (*SearchOptions) Validate

func (o *SearchOptions) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL