options

package
v0.0.0-...-52010a8 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2015 License: Unlicense Imports: 2 Imported by: 2

Documentation

Overview

The options package includes some default option parsers for the requests package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequiredMissing = errors.New("Required value has nil input")
	ErrValueImmutable  = errors.New("Value is immutable once set")
)

Functions

func Default

func Default(orig, value interface{}, fromRequest bool, optionValue string) (interface{}, error)

Default is an option func that sets a default value for a field. If its value is non-empty, it will use the following logic to decide what to return:

If fromRequest is false, then the default will be returned if orig is equal to its zero value.

If fromRequest is true, then the default will be returned if value is nil.

In all other cases, value will be returned.

func Immutable

func Immutable(orig, value interface{}, fromRequest bool, optionValue string) (interface{}, error)

Immutable is an option func that ensures that a value is not modified after being set. It will return an error if orig is non-empty and does not match the new value from the request.

func Required

func Required(orig, value interface{}, fromRequest bool, optionValue string) (interface{}, error)

Required is an option func that ensures a non-nil value was passed along in the request. It does not ensure that the value is non-empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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