Documentation ¶
Index ¶
- Variables
- func As[T any](v any) (T, error)
- func AsBool(v any) bool
- func AsByteArray(v any) ([]byte, bool)
- func AsFloat(v any) (float64, bool)
- func AsInt(v any) (int64, bool)
- func AsNumber(v any) (any, bool)
- func AsString(v any) (string, bool)
- func AsUint(v any) (uint64, bool)
- func Assign(dst, src any) error
- func AssignReflect(vdst, vsrc reflect.Value) error
- func BaseType(v any) any
- func DeepClone[T any](v T) T
- func DeepCloneReflect(src reflect.Value) reflect.Value
- func Equal(a, b any) bool
- func Flatten(a any) any
- func IsNil(v any) bool
- func Math(mathop string, a, b any) (any, bool)
- func OffsetGet(ctx context.Context, v any, offset string) (any, error)
- func SetValidator[T any](validator string, fnc func(T) error)
- func SetValidatorArgs(validator string, fnc any)
- func ToType(ref, v any) (any, bool)deprecated
- func Validate(obj any) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrAssignDestNotPointer = errors.New("assign destination must be a pointer") ErrAssignImpossible = errors.New("the requested assign is not possible") ErrNilPointerRead = errors.New("attempt to read from a nil pointer") ErrEmptyValue = errors.New("validator: value must not be empty") ErrDestinationNotAddressable = errors.New("assign: destination cannot be addressed") ErrStructPtrRequired = errors.New("parameter must be a pointer to a struct") ErrBadOffset = errors.New("bad offset type") )
Functions ¶
func AsByteArray ¶ added in v0.1.14
AsByteArray will loosely convert the given value to a byte array
func AsNumber ¶
AsNumber will loosely convert n in one of int64, uint64 or float64 depending on what feels best
func Assign ¶ added in v0.1.5
Assign sets dst to the value of src. In case src is any kind of container, a shallow copy is performed
func AssignReflect ¶ added in v0.1.19
func BaseType ¶ added in v0.1.4
BaseType attempts to convert v into its base type, that is if v is a type that is defined as `type foo string`, a simple string will be returned.
func DeepClone ¶ added in v0.2.9
func DeepClone[T any](v T) T
DeepClone performs a deep duplication of the provided argument, and returns the newly created object
func DeepCloneReflect ¶ added in v0.2.9
DeepCloneReflect performs a deep duplication of the provided reflect.Value
func Flatten ¶ added in v0.2.8
Flatten transforms a into a simple interface, even if it is contains multiple levels. *string becomes string (or nil if it's nil), etc
func IsNil ¶ added in v0.2.8
IsNil recursively checks if v is nil, even if it is a pointer of an interface of a ...
func Math ¶ added in v0.1.16
Math performs a mathematical operation on two variables of any type and returns a numeric type and true if everything went fine.
For example Math("+", 40.000, "2") will return float64(42)
For now if passed any float value, the function will always return a float value in the end. This may change in the future.
func OffsetGet ¶ added in v0.2.6
OffsetGet returns v[offset] dealing with various case of figure. ctx will be passed to some methods handling it
func SetValidator ¶ added in v0.1.6
SetValidator sets the given function as validator with the given name. This should be typically called in init()
func SetValidatorArgs ¶ added in v0.1.13
Types ¶
This section is empty.