package guarded

import "go.trulyao.dev/robin/internal/guarded"

Index

Functions

func CastType

func CastType[Target any](from any, to Target) (Target, error)

CastType attempts to cast the given value to the target type If the value is nil, it will return the target value If the value is already of the correct type, it will return it Numbers are a bit tricky, they are automatically converted to float64 when unmarshalled from JSON, so we need to check for that and convert to what we expect

See implementation for more details

func ExpectsPayload

func ExpectsPayload(param any) types.ExpectedPayloadType

ExpectsPayload returns whether the given parameter expects a payload or not by checking if it is a void type

func MakeCastError

func MakeCastError(expected, got any) error

Attempts to construct a CastError from the expected and gotten types

Source Files

cast.go check.go

Version
v0.8.2 (latest)
Published
Apr 4, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
9 hours ago

Tools for package owners.