package vo

import "fmt"

// OrderType is a value object representing the type of an order.
type OrderType string

const (
	Limit  OrderType = "limit"
	Market OrderType = "market"
)

// ValidOrderTypes lists all valid OrderType values.
var ValidOrderTypes = []OrderType{Limit, Market}

// NewOrderType creates a validated OrderType from a string.
func NewOrderType(s string) (OrderType, error) {
	t := OrderType(s)
	if t != Limit && t != Market {
		return "", fmt.Errorf("invalid order type: %q, must be 'limit' or 'market'", s)
	}
	return t, nil
}

// String returns the string representation of the OrderType.
func (t OrderType) String() string {
	return string(t)
}

// IsValid returns true if the OrderType is a recognized value.
func (t OrderType) IsValid() bool {
	return t == Limit || t == Market
}
