-
Notifications
You must be signed in to change notification settings - Fork 0
/
internal.go
79 lines (71 loc) · 1.74 KB
/
internal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package aform
import (
"golang.org/x/text/language"
"html/template"
"net/http"
)
// verify interface compliance
var _ formInterface = (*Form)(nil)
type formInterface interface {
AsDiv() template.HTML
BindRequest(req *http.Request)
BindData(data map[string][]string, langs ...string)
IsBound() bool
Fields() []*Field
FieldByName(field string) (*Field, error)
IsValid() bool
CleanedData() CleanedData
Errors() FormErrors
SetCleanFunc(clean func(*Form))
AddError(field string, err error) error
// CharField(name string) CharField
// EmailField(name string) EmailField
}
type fieldInterface interface {
Type() FieldType
fieldInitializer
fieldCustomizer
fieldRenderer
fieldReader
field() *Field
}
type fieldInitializer interface {
SetLabel(label string)
MarkSafe()
SetHelpText(help string)
SetNotRequired()
SetDisabled()
AddChoiceOptions(label string, options []ChoiceFieldOption)
addError(err Error)
}
type fieldCustomizer interface {
SetLabelSuffix(labelSuffix string)
CustomizeError(err ErrorCoderTranslator)
SetAutoID(autoID string) error
SetRequiredCSSClass(class string)
SetErrorCSSClass(class string)
SetAttributes(attrs []Attributable)
SetWidget(widget Widget)
SetLocale(locale language.Tag)
SetSanitizeFunc(update func(current SanitizationFunc) (new SanitizationFunc))
SetValidateFunc(update func(current ValidationFunc) (new ValidationFunc))
}
type fieldRenderer interface {
AsDiv() template.HTML
LabelTag() template.HTML
LegendTag() template.HTML
Widget() template.HTML
Errors() template.HTML
HelpText() template.HTML
}
type fieldReader interface {
Name() string
HTMLName() string
AutoID() string
LabelSuffix() string
UseFieldset() bool
CSSClasses() string
Required() bool
HasHelpText() bool
HasErrors() bool
}