frm

package
v2.0.0-...-2d9c7e5 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 11 Imported by: 0

README

frm Library

Error codes.

Installation

go import "github.com/getevo/evo/v2/lib/frm"

Features

  • Configuration Options: Flexible settings for customizing behavior

Usage Examples

Basic Usage

`go package main

import ( "fmt" "github.com/getevo/evo/v2/lib/frm" )

func main() { // Example usage of frm library frm.NewDecoder() } `

How It Works

The frm library is designed to be simple to use while providing powerful functionality. It integrates seamlessly with other components of the EVO Framework.

For more detailed information, please refer to the source code and comments within the library.

Documentation

Overview

Package frm decodes HTTP form and query parameters.

Index

Constants

View Source
const (
	ErrCodeNotAPointer  uint8 = iota // Didn't pass a pointer to Decode().
	ErrCodeArrayIndex                // Error attempting to use an array index (e.g. foo[2]).
	ErrCodeConversion                // Error converting field to the type.
	ErrCodeUnknownType               // Unknown type.
	ErrCodeUnknownField              // No struct field for passed parameter (will never be used if IgnoreUnknownKeys is set).
	ErrCodeRange                     // Number is out of range (e.g. parsing 300 in uint8 would overflow).
	ErrCodeArraySize                 // Array longer than MaxSize.
)

Error codes.

Variables

This section is empty.

Functions

func Decode

func Decode(vs url.Values, dst any) error

Decode the url.Values and populate the destination dst, which must be a pointer.

Types

type DecodeCustomTypeFunc

type DecodeCustomTypeFunc func([]string) (any, error)

DecodeCustomTypeFunc for decoding a custom type.

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder to decode a form.

func NewDecoder

func NewDecoder(opts *DecoderOptions) *Decoder

NewDecoder creates a new instance of Decoder.

func (Decoder) Decode

func (dec Decoder) Decode(vs url.Values, dst any) error

Decode the url.Values and populate the destination dst, which must be a pointer.

func (*Decoder) RegisterCustomType

func (dec *Decoder) RegisterCustomType(fn DecodeCustomTypeFunc, types []any, fields []any) *Decoder

RegisterCustomType registers a functions for decoding custom types.

type DecoderOptions

type DecoderOptions struct {
	// Struct field tag name; default is "formam".
	TagName string

	// Prefer UnmarshalText over custom types.
	PrefUnmarshalText bool

	// Disable UnmarshalText interface
	DisableUnmarshalText bool

	// Ignore unknown form fields. By default unknown fields are an error
	// (although all valid keys will still be decoded).
	IgnoreUnknownKeys bool

	// The maximum array size that formam will create. This is limited to
	// prevent malicious input to create huge arrays to starve the server of
	// memory.
	//
	// The default is 16,000; set to -1 to disable.
	MaxSize int
}

DecoderOptions options for decoding the values.

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error indicates a error produced

func (*Error) Cause

func (s *Error) Cause() error

Cause implements the causer interface from github.com/pkg/errors.

func (Error) Code

func (s Error) Code() uint8

Code for this error. See the ErrCode* constants.

func (*Error) Error

func (s *Error) Error() string

func (Error) MarshalJSON

func (s Error) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface Marshaler

func (Error) Path

func (s Error) Path() string

Path for this error.

Jump to

Keyboard shortcuts

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