Documentation
¶
Overview ¶
Package pair can represent 1:1 mappings between two different APIs, such that validation errors are transformed.
Index ¶
- func Const[T any](value T) *T
- func Make[From, Into any](registry Registry, mapping func(from *From, into *Into) []Field) (func(From) Into, func(Into) From, func(error) error)
- type Error
- type Field
- func Bool[From ~bool, Into ~bool](from *From, into *Into) Field
- func Complex128[From ~complex128, Into ~complex128](from *From, into *Into) Field
- func Complex64[From ~complex64, Into ~complex64](from *From, into *Into) Field
- func Float32[From ~float32, Into ~float32](from *From, into *Into) Field
- func Float64[From ~float64, Into ~float64](from *From, into *Into) Field
- func Int[From ~int, Into ~int](from *From, into *Into) Field
- func Int16[From ~int16, Into ~int16](from *From, into *Into) Field
- func Int32[From ~int32, Into ~int32](from *From, into *Into) Field
- func Int64[From ~int64, Into ~int64](from *From, into *Into) Field
- func Int8[From ~int8, Into ~int8](from *From, into *Into) Field
- func Map[FromKey, IntoKey comparable, FromVal, IntoVal any](from *map[FromKey]FromVal, into *map[IntoKey]IntoVal, ...) Field
- func Slice[From, Into any](from *[]From, into *[]Into, rule func(*From, *Into) Field) Field
- func String[From ~string, Into ~string](from *From, into *Into) Field
- func Uint[From ~uint, Into ~uint](from *From, into *Into) Field
- func Uint16[From ~uint16, Into ~uint16](from *From, into *Into) Field
- func Uint32[From ~uint32, Into ~uint32](from *From, into *Into) Field
- func Uint64[From ~uint64, Into ~uint64](from *From, into *Into) Field
- func Uint8[From ~uint8, Into ~uint8](from *From, into *Into) Field
- func Uintptr[From ~uintptr, Into ~uintptr](from *From, into *Into) Field
- type Registry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Const ¶
func Const[T any](value T) *T
Const returns a constant value, that is assumed to always be present on one side of an API pairing.
func Make ¶
func Make[From, Into any](registry Registry, mapping func(from *From, into *Into) []Field) (func(From) Into, func(Into) From, func(error) error)
Make a 1:1 mapping function that maps from -> into and into -> from, as well as an error wrapper that transforms field-specific errors from one API space into the other.
Types ¶
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field represents a 1:1 mapping between two fields.
func Complex128 ¶
func Complex128[From ~complex128, Into ~complex128](from *From, into *Into) Field
Complex128 pairs two complex128 fields together.
func Map ¶
func Map[FromKey, IntoKey comparable, FromVal, IntoVal any]( from *map[FromKey]FromVal, into *map[IntoKey]IntoVal, keyRule func(*FromKey, *IntoKey) Field, valRule func(*FromVal, *IntoVal) Field, ) Field
Map pairs two map fields together.
Click to show internal directories.
Click to hide internal directories.