secureform

package module
v0.0.0-...-55f6e39 Latest Latest
Warning

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

Go to latest
Published: May 23, 2018 License: MIT Imports: 9 Imported by: 2

README

secureform GoDoc Go Report Card Coverage

Go package to easily and securely validate form field values.

go get github.com/oftn-oswg/secureform

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExpectedStructPtr = errors.New("Invalid field interface, expected struct pointer")

ErrExpectedStructPtr is produced when a type other than a struct pointer is passed to be populated.

View Source
var ErrInvalidKind = errors.New("Invalid field kind, expected string, bool, numeric, secureform.Type, or secureform.File")

ErrInvalidKind is produced when a struct field has an unsupported type. Currently, only string, bool, numeric, secureform.Type and secureform.File types are supported.

View Source
var ErrValidMax = errors.New("Result falls above maximum range")

ErrValidMax is produced when a form value or string length is too large.

View Source
var ErrValidMin = errors.New("Result falls below minimum range")

ErrValidMin is produced when a form value or string length is too small.

Functions

This section is empty.

Types

type FieldError

type FieldError struct {
	Name string
	Err  error
}

FieldError is an error that relates to a specific struct field.

func (*FieldError) Error

func (err *FieldError) Error() string

type File

type File struct {
	*multipart.FileHeader
}

File represents a form input element such as <input type="file" />

type Parser

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

Parser defines the security parameters for form parsing.

func NewParser

func NewParser(memory, bytes, stringLen int64) *Parser

NewParser allocates and returns a new Parser with the specified properties.

The memory paramater is the maximum memory used before writing extra to the disk with multipart form data. The bytes parameter is the maximum size request body before sending an error back to the client. The stringLen parameter is the maximum size string allowed in a string form field.

func (*Parser) Parse

func (parser *Parser) Parse(w http.ResponseWriter, r *http.Request, fields interface{}) (err error)

Parse parses the form with the options of the parser and loads the results into the fields struct.

type Type

type Type interface {
	Set(value string) error
}

Type represents an arbitrary interface for parsing

Jump to

Keyboard shortcuts

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