types

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package types holds framework value types that are shared by generated models, handler DTOs, and the admin data plane. They exist so a single Go type flows through the model, the Huma contract (OpenAPI/TS client), and GORM persistence without the DTO drifting from the model (see #222 / #218).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decimal

type Decimal struct {
	decimal.Decimal
}

Decimal is a fixed-point decimal for money and other exact numeric values.

It wraps shopspring/decimal.Decimal, so it inherits exact arithmetic, JSON (a quoted string — no float rounding), text (un)marshaling, and the database sql.Scanner / driver.Valuer used by GORM. On top of that it advertises an OpenAPI schema (a string with format "decimal") via huma.SchemaProvider, so the generated OpenAPI document and TypeScript client see a string instead of an opaque object. Use the gorm tag `type:decimal(p,s)` on the model field to pin precision/scale for the migration (gombit make resource emits decimal(19,4) by default).

func NewDecimal

func NewDecimal(d decimal.Decimal) Decimal

NewDecimal wraps a shopspring decimal.

func NewDecimalFromString

func NewDecimalFromString(s string) (Decimal, error)

NewDecimalFromString parses a decimal string (e.g. "19.99").

func (Decimal) GormDataType

func (Decimal) GormDataType() string

GormDataType tells GORM the default column family when a model field omits an explicit `type:` tag. Generated models pin exact precision with `gorm:"type:decimal(19,4)"`, which takes precedence over this default.

func (Decimal) Schema

func (Decimal) Schema(huma.Registry) *huma.Schema

Schema implements huma.SchemaProvider so the contract represents a Decimal as a JSON string (matching its MarshalJSON), not a reflected struct.

Jump to

Keyboard shortcuts

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