form

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Unparsed string
	Parsed   interface{}
	Error    error
}

type FieldTemplate

type FieldTemplate interface {
	GetName() string
	Parse(unparsed string) (interface{}, error)
	Validate(value interface{}) error
}

type Form

type Form struct {
	Fields map[string]*Field
}

func (*Form) IsValid

func (f *Form) IsValid() bool

type FormTemplate

type FormTemplate struct {
	CustomValidate func(*Form)
	// contains filtered or unexported fields
}

func NewFormTemplate

func NewFormTemplate() (f *FormTemplate)

func (*FormTemplate) AddField

func (f *FormTemplate) AddField(fieldTemplate FieldTemplate)

func (*FormTemplate) New

func (f *FormTemplate) New() (s *Form)

func (*FormTemplate) Parse

func (f *FormTemplate) Parse(values url.Values) (s *Form)

func (*FormTemplate) Validate

func (f *FormTemplate) Validate(s *Form)

type IntTemplate

type IntTemplate struct {
	Name     string
	Required bool
	Minimum  int64
	Maximum  int64
}

func (*IntTemplate) GetName

func (f *IntTemplate) GetName() string

func (*IntTemplate) Parse

func (f *IntTemplate) Parse(unparsed string) (interface{}, error)

func (*IntTemplate) Validate

func (f *IntTemplate) Validate(value interface{}) error

type StringTemplate

type StringTemplate struct {
	Name      string
	Required  bool
	MinLength int
	MaxLength int
}

func (*StringTemplate) GetName

func (f *StringTemplate) GetName() string

func (*StringTemplate) Parse

func (f *StringTemplate) Parse(unparsed string) (interface{}, error)

func (*StringTemplate) Validate

func (f *StringTemplate) Validate(value interface{}) (err error)

type TooLongError

type TooLongError struct {
	Maximum int
}

func (TooLongError) Error

func (e TooLongError) Error() string

type TooShortError

type TooShortError struct {
	Minimum int
}

func (TooShortError) Error

func (e TooShortError) Error() string

Jump to

Keyboard shortcuts

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