form

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package form provides utilities for decoding HTTP form values into structs. It supports both standard and multipart forms, and can handle nested structs, slices, pointers, and custom decoders via struct tags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r *http.Request, dst any) error

Decode parses form values from an *http.Request and populates the fields of dst, which MUST BE a pointer to a struct.

This function supports both standard and multipart forms, and can decode nested structs, slices, and pointers. Fields can be tagged with `form` to specify the form key. Returns an error if decoding fails or if dst is not a pointer to a struct.

func RegisterCustomTypeFunc

func RegisterCustomTypeFunc(fn func(string) (any, error), customType any)

RegisterCustomTypeFunc registers a custom decoder function for a specific type. The decoder function should accept a string and return the decoded value or an error. This allows Decode to handle custom types beyond the built-in decoders.

func Validate

func Validate(req *http.Request, rules validator) validate.Errors

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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