Documentation
¶
Overview ¶
Package enums validates string-backed enums and adapts them to JSON and database/sql.
An enum that declares "" as a member treats "" as its unset value: Scan reads SQL NULL as "", Unmarshal reads JSON null as "", and Value and Marshal write "" as the empty string. A non-pointer enum that does not declare "" rejects "", SQL NULL and JSON null; a *Enum field takes NULL and null as nil without calling Scan or Unmarshal.
Index ¶
- func Marshal[Enum ~string](value Enum, allowed map[Enum]struct{}) ([]byte, error)
- func Scan[Enum ~string](src any, out *Enum, allowed map[Enum]struct{}) error
- func Set[Enum ~string](vals []Enum) map[Enum]struct{}
- func Unmarshal[Enum ~string](b []byte, out *Enum, allowed map[Enum]struct{}) error
- func Validate[Enum ~string](value Enum, allowed map[Enum]struct{}) error
- func Value[Enum ~string](value Enum, allowed map[Enum]struct{}) (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.