enums

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package enums provides generic SQL Valuer/Scanner helpers for string-based enum types whose set of valid values is exposed via a Valid() method.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpectedScanType = errors.New("unexpected scan type")

Functions

func Scan

func Scan[T Validator](src any, out *T, invalidErr error) error

Scan implements sql.Scanner. nil clears to the zero value; string and []byte are accepted and validated via Valid().

func Value

func Value[T Validator](v T, invalidErr error) (driver.Value, error)

Value implements driver.Valuer. Empty values become SQL NULL; non-empty values must satisfy v.Valid().

Types

type Validator

type Validator interface {
	~string
	Valid() bool
}

Validator is satisfied by string-based enum types that report membership in their valid set via Valid().

Jump to

Keyboard shortcuts

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