gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

form.go (1171B)


      1 package form
      2 
      3 import (
      4 	"reflect"
      5 	"time"
      6 )
      7 
      8 const (
      9 	blank     = ""
     10 	ignore    = "-"
     11 	fieldNS   = "Field Namespace:"
     12 	errorText = " ERROR:"
     13 )
     14 
     15 var (
     16 	timeType = reflect.TypeOf(time.Time{})
     17 )
     18 
     19 // Mode specifies which mode the form decoder is to run
     20 type Mode uint8
     21 
     22 const (
     23 
     24 	// ModeImplicit tries to parse values for all
     25 	// fields that do not have an ignore '-' tag
     26 	ModeImplicit Mode = iota
     27 
     28 	// ModeExplicit only parses values for field with a field tag
     29 	// and that tag is not the ignore '-' tag
     30 	ModeExplicit
     31 )
     32 
     33 // AnonymousMode specifies how data should be rolled up
     34 // or separated from anonymous structs
     35 type AnonymousMode uint8
     36 
     37 const (
     38 	// AnonymousEmbed embeds anonymous data when encoding
     39 	// eg. type A struct { Field string }
     40 	//     type B struct { A, Field string }
     41 	//     encode results: url.Values{"Field":[]string{"B FieldVal", "A FieldVal"}}
     42 	AnonymousEmbed AnonymousMode = iota
     43 
     44 	// AnonymousSeparate does not embed anonymous data when encoding
     45 	// eg. type A struct { Field string }
     46 	//     type B struct { A, Field string }
     47 	//     encode results: url.Values{"Field":[]string{"B FieldVal"}, "A.Field":[]string{"A FieldVal"}}
     48 	AnonymousSeparate
     49 )