Documentation
¶
Index ¶
- Variables
- func ConvertToGeneric[T any](v any) (T, error)
- func Deref(v any) (val any, ok bool)
- func DerefAll(v any) any
- func ExtractString(v any) (str string, ok bool)
- func GetLength(v any) (length int, ok bool)
- func GetSize(v any) (size int, ok bool)
- func HasLength(v any) bool
- func HasSize(v any) bool
- func IsArray(v any) bool
- func IsBigInt(v any) bool
- func IsBool(v any) bool
- func IsChan(v any) bool
- func IsComparable(v any) bool
- func IsComplex(v any) bool
- func IsError(v any) bool
- func IsFloat(v any) bool
- func IsFunc(v any) bool
- func IsInt(v any) bool
- func IsInterface(v any) bool
- func IsIterable(v any) bool
- func IsMap(v any) bool
- func IsNil(v any) bool
- func IsNumber(v any) bool
- func IsNumeric(v any) bool
- func IsPointer(v any) bool
- func IsSlice(v any) bool
- func IsString(v any) bool
- func IsStringer(v any) bool
- func IsStruct(v any) bool
- func IsUint(v any) bool
- func IsValid(v any) bool
- func IsZero(v any) bool
- func ParsedCategory(v any) string
- func ParsedKind(v any) reflect.Kind
- func ParsedType(v any) core.ParsedType
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilValue = errors.New("cannot convert nil") ErrUnsupportedConversion = errors.New("unsupported conversion") )
Sentinel errors returned by ConvertToGeneric.
Functions ¶
func ConvertToGeneric ¶
ConvertToGeneric converts arbitrary value v into type T using reflection only when necessary. It returns zero value of T plus an error when conversion is impossible. Fast paths are kept extremely short for performance.
func Deref ¶
Deref returns the value pointed to by v. If v is nil, not a pointer, or the pointer is nil, it returns (nil, false). When v is not a pointer the value is returned as-is with ok = true.
func DerefAll ¶
DerefAll recursively follows pointer chains until a non-pointer value (or nil) is reached. A nil input or nil pointer yields nil.
func ExtractString ¶
ExtractString returns the string value if v is a string. Otherwise ok=false.
func HasLength ¶
HasLength reports whether v supports the built-in len() function (string, array, slice).
func IsComparable ¶
IsComparable checks if a value's type is comparable
func IsIterable ¶
IsIterable checks if a value can be iterated (array, slice, map, string)
func IsNumber ¶ added in v0.3.1
IsNumber checks if a value is any numeric type (alias for IsNumeric)
func IsStringer ¶
IsStringer checks if a value implements the fmt.Stringer interface
func ParsedCategory ¶
ParsedCategory returns the general category of a type
func ParsedKind ¶
ParsedKind returns the reflect.Kind of a value
func ParsedType ¶
func ParsedType(v any) core.ParsedType
ParsedType returns the parsed type for runtime type detection This corresponds to Zod v4's getParsedType() function which returns ParsedTypes See: .reference/zod/packages/zod/src/v4/core/util.ts:412
Types ¶
This section is empty.