fork

package module
v0.0.0-...-56d1b51 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2015 License: MIT Imports: 15 Imported by: 1

README

Fork

Build Status GoDoc Coverage Status license

A framework agnostic web form construction & destruction kit for Go.

https://thrisp.github.io/fork/

Documentation

Index

Constants

View Source
const Timeout = 12 * time.Hour

Variables

View Source
var BadCheck = ForkError(`check function did not return a boolean value with its error.`)
View Source
var InvalidFunction = ForkError(`cannot use function %q with %d results, return must be %s`).Out
View Source
var NotAFunction = ForkError(`#+v is not a function`).Out
View Source
var UnassignableArg = ForkError(`arg %d has type %s; should be %s`).Out
View Source
var WrongNumberArgs = ForkError(`wrong number of args: got %d want at least %d`).Out

Functions

func Check

func Check(fn reflect.Value, args ...interface{}) (bool, error)

func Filter

func Filter(fn reflect.Value, args ...interface{}) interface{}

func ForkError

func ForkError(err string) *forkError

func NewFilterTime

func NewFilterTime(format string) func(string) string

func NewProcessor

func NewProcessor(w Widget, v Validater, f Filterer) *processor

func ValidEmail

func ValidEmail(t *textField) error

func Validate

func Validate(fn reflect.Value, args ...interface{}) error

func ValidateIndex

func ValidateIndex(f *formField) error

func ValidateTime

func ValidateTime(t *timeField) error

func ValidateXsrf

func ValidateXsrf(x *xsrf) error

func WithOptions

func WithOptions(base string, options ...string) string

Types

type Checker

type Checker interface {
	Checkable() bool
	SetCheckable(bool) bool
	Check(Form) (bool, error)
	Ok(Form) bool
	Error(f Form) bool
	Errors(f Form) []string
	Checks(...interface{}) []reflect.Value
}

func NewChecker

func NewChecker(c ...interface{}) Checker

type Creator

type Creator interface {
	New() Form
	Configure(...FormConfig) error
}

type Field

type Field interface {
	Named
	New(...interface{}) Field
	Get() *Value
	Set(*http.Request)
	Processor
}

func BooleanField

func BooleanField(name string, label string, start bool, options ...string) Field

func CheckboxInput

func CheckboxInput(name string, label string, value string, checked bool, options ...string) Field

func DateField

func DateField(name string, options ...string) Field

func EmailField

func EmailField(name string, v []interface{}, f []interface{}, options ...string) Field

func FormField

func FormField(name string, f Form) Field

func FormsField

func FormsField(name string, startwith int, start Form) Field

func HiddenField

func HiddenField(name string, v []interface{}, f []interface{}, options ...string) Field

func ListField

func ListField(name string, startwith int, starting Field, options ...string) Field

func PassWordField

func PassWordField(name string, v []interface{}, f []interface{}, options ...string) Field

func RadioField

func RadioField(name string, legend string, s []*Selection, v []interface{}, f []interface{}, options ...string) Field

func RadioInput

func RadioInput(name string, label string, value string, checked bool, options ...string) Field

func SelectField

func SelectField(name string, s []*Selection, v []interface{}, f []interface{}, options ...string) Field

func SubmitField

func SubmitField(name string, v []interface{}, f []interface{}, options ...string) Field

func TextAreaField

func TextAreaField(name string, v []interface{}, f []interface{}, options ...string) Field

func TextField

func TextField(name string, v []interface{}, f []interface{}, options ...string) Field

func TimeField

func TimeField(name string, format string, widget Widget, v []interface{}, f []interface{}) Field

func ToggleInput

func ToggleInput(name string, label string, value string, widget Widget, checked bool) Field

func XSRF

func XSRF(name string, secret string) Field

type FieldIndex

type FieldIndex struct {
	I int
	N string
}

func FilterIndex

func FilterIndex(index string) *FieldIndex

func NewFieldIndex

func NewFieldIndex(s string, i int) *FieldIndex

type Filterer

type Filterer interface {
	Filter(string, *http.Request) *Value
	Filters(...interface{}) []reflect.Value
}

func NewFilterer

func NewFilterer(f ...interface{}) Filterer

type Form

type Form interface {
	Tagged
	Creator
	Former
	Renderer
	Informer
	Checker
}

func NewForm

func NewForm(tag string, fc ...FormConfig) Form

type FormConfig

type FormConfig func(Form) error

func Checks

func Checks(cs ...interface{}) FormConfig

func Fields

func Fields(fs ...Field) FormConfig

type Former

type Former interface {
	Fields(...Field) []Field
	Process(*http.Request)
}

type Informer

type Informer interface {
	Values() map[string]*Value
}

type Named

type Named interface {
	Name() string
	ReName(...string) string
}

type Processor

type Processor interface {
	Widget
	Filterer
	Validater
}

type Renderer

type Renderer interface {
	Buffer() *bytes.Buffer
	String() string
	Render() template.HTML
}

type Selection

type Selection struct {
	Value string
	Label string
	Set   bool
}

func NewSelection

func NewSelection(value string, label string, set bool) *Selection

type Tagged

type Tagged interface {
	Tag() string
}

type Validater

type Validater interface {
	Validateable() bool
	SetValidateable(bool) bool
	Validate(Field) error
	Valid(Field) bool
	Error(Field) bool
	Errors(Field) []string
	Validaters(...interface{}) []reflect.Value
}

func NewValidater

func NewValidater(v ...interface{}) Validater

type Value

type Value struct {
	Raw  interface{}
	Type reflect.Type
	Kind reflect.Kind
}

func NewValue

func NewValue(i interface{}) *Value

func (*Value) Bool

func (v *Value) Bool() bool

func (*Value) Integer

func (v *Value) Integer() int

func (*Value) String

func (v *Value) String() string

type Widget

type Widget interface {
	Bytes(interface{}) (*bytes.Buffer, error)
	String(interface{}) string
	Render(Field) template.HTML
	RenderWith(map[string]interface{}) template.HTML
}

func NewWidget

func NewWidget(t string) Widget

Jump to

Keyboard shortcuts

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