forked from go-playground/form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.go
50 lines (40 loc) · 1.2 KB
/
form.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
package form
import (
"reflect"
"time"
)
const (
blank = ""
namespaceSeparator = '.'
ignore = "-"
fieldNS = "Field Namespace:"
errorText = " ERROR:"
)
var (
timeType = reflect.TypeOf(time.Time{})
)
// Mode specifies which mode the form decoder is to run
type Mode uint8
const (
// ModeImplicit tries to parse values for all
// fields that do not have an ignore '-' tag
ModeImplicit Mode = iota
// ModeExplicit only parses values for field with a field tag
// and that tag is not the ignore '-' tag
ModeExplicit
)
// AnonymousMode specifies how data should be rolled up
// or separated from anonymous structs
type AnonymousMode uint8
const (
// AnonymousEmbed embeds anonymous data when encoding
// eg. type A struct { Field string }
// type B struct { A, Field string }
// encode results: url.Values{"Field":[]string{"B FieldVal", "A FieldVal"}}
AnonymousEmbed AnonymousMode = iota
// AnonymousSeparate does not embed anonymous data when encoding
// eg. type A struct { Field string }
// type B struct { A, Field string }
// encode results: url.Values{"Field":[]string{"B FieldVal"}, "A.Field":[]string{"A FieldVal"}}
AnonymousSeparate
)