Documentation
¶
Overview ¶
Package nullable contains nullable types used to handle scenarios where default values can't be used to indicate empty, and we want to avoid using pointers for that.
Index ¶
- Variables
- type Parser
- type Value
- func New[T nullable](v T) Value[T]
- func Parse[T nullable](q url.Values, key string, parser Parser[T]) (Value[T], error)
- func ParseBool(s string) (Value[bool], error)
- func ParseFloat(s string) (Value[float64], error)
- func ParseInt(s string) (Value[int], error)
- func ParseString(s string) (Value[string], error)
- func ParseU16(s string) (Value[uint16], error)
- func ParseU64(s string) (Value[uint64], error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidQueryParams = errors.New("invalid query parameters")
Functions ¶
This section is empty.
Types ¶
type Parser ¶
Parser[T any] represents a parser function. It is used to avoid a single parser for all nullables for improved readability and performance. Parser should always return Nullable with Set=true, error otherwise.
type Value ¶
Value type is used to represent difference betweeen an intentionally omitted value and default type value.
func (Value[T]) MarshalJSON ¶
MarshalJSON encodes the value if set, otherwise returns `null`.
func (*Value[T]) UnmarshalJSON ¶
UnmarshalJSON decodes JSON and sets the value and Set flag.
Click to show internal directories.
Click to hide internal directories.