form

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertFormDataToHTMLTypeMap

func ConvertFormDataToHTMLTypeMap(data map[string][]string) (map[string]HTMLType, error)

func FieldValueIsValid

func FieldValueIsValid(field Field, value interface{}) ([]error, error)

func GetCleanData

func GetCleanData(form Form, values map[string]HTMLType) (map[string]interface{}, error)

func RenderFormAsP

func RenderFormAsP(form Form, formErrs []error, fieldsErrs map[string][]error) (string, error)

func RenderFormAsTable

func RenderFormAsTable(form Form, formErrs []error, fieldsErrs map[string][]error) (string, error)

func RenderFormAsUL

func RenderFormAsUL(form Form, formErrs []error, fieldsErrs map[string][]error) (string, error)

func ValuesAreValid

func ValuesAreValid(form Form, values map[string]interface{}) ([]error, map[string][]error, error)

Types

type Field

type Field interface {
	HTML() (string, error)
	GoTypeToHTMLType(value interface{}) (HTMLType, error)
	HTMLTypeToGoType(value HTMLType) (interface{}, error)
	RegisterValidationFunctions(validationFuncs ...FieldValidationFunc)
	GetValidationFunctions() []FieldValidationFunc
	GetName() string
	RegisterName(name string) error
	RegisterInitialValue(value interface{})
	SetSupersedingAttribute(name string, value *string)
	RegisterLabel(label string) error
	GetLabel() string
}

type FieldValidationFunc

type FieldValidationFunc func(value interface{}) (frontend []error, backend error)

type Form

type Form interface {
	AddField(name string, field Field) error
	GetFields() []Field
	RegisterValidationFunctions(validationFuncs ...ValidationFunc)
	GetValidationFunctions() []ValidationFunc
	RegisterInitialValues(values map[string]interface{}) error
	Save(values map[string]HTMLType) (interface{}, error)
}

type HTMLType

type HTMLType string

type ValidationFunc

type ValidationFunc func(map[string]interface{}) (frontend []error, backend error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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