reflectx

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package reflectx holds pure reflection helpers extracted from the validate root package. It depends only on goutil and never imports the root package, keeping the dependency direction one-way (root -> internal/reflectx).

Index

Constants

This section is empty.

Variables

View Source
var ErrConvertFail = errors.New("convert value is failure")

ErrConvertFail error. Mirrors validate.ErrConvertFail; kept as a separate value because consumers only test err != nil, never the identity.

View Source
var NilRVal = reflect.ValueOf(nilObj)

NilRVal a reflect nil value (= reflect.ValueOf(NilObject{})).

Functions

func ConvToBasicType

func ConvToBasicType(val any) (value any, err error)

ConvToBasicType convert custom type to generic basic int, string, unit. returns string, int64 or error

func ConvTypeByBaseKind

func ConvTypeByBaseKind(srcVal any, dstType reflect.Kind) (any, error)

ConvTypeByBaseKind convert value type by base kind

func GetVariadicKind

func GetVariadicKind(typ reflect.Type) reflect.Kind

GetVariadicKind name.

usage:

GetVariadicKind(reflect.TypeOf(v))

func IndirectValue

func IndirectValue(input any) any

IndirectValue dereferences a single pointer level of the input value.

func IsNilObj

func IsNilObj(val any) bool

IsNilObj check value is internal NilObject

func RemoveValuePtr

func RemoveValuePtr(t reflect.Value) reflect.Value

RemoveValuePtr removes value multiple pointer

func ValueCompare

func ValueCompare(srcVal, dstVal any, op string) (ok bool)

ValueCompare value compare.

only check for: int(X), uint(X), float(X), string.

Types

type NilObject

type NilObject struct{}

NilObject represent nil value for calling functions and should be reflected at custom filters as nil variable.

NOTE: validate.NilObject is a type alias of this type, so the public API and any val.(NilObject) assertion in user code keep working unchanged.

Jump to

Keyboard shortcuts

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