Documentation ¶
Overview ¶
The fields package contains all the fields to represent forms and their associated metadata. Each of these matches a field in the [Fields](http://docs.typeform.io/docs/introduction) section of their api documentation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field struct { Type FieldType `json:"type" bson:"t"` Question string `json:"question" bson:"q" validate:"nonzero,max=512"` Ref string `json:"ref,omitempty" bson:"r,omitempty" validate:"max=128"` Description string `json:"description,omitempty" bson:"d" validate:"max=512"` Required bool `json:"required,omitempty" bson:"req,omitempty"` Tags []string `json:"tags,omitempty" bson:"g,omitempty" validate:"arrMap=min=1,arrMap=max=128,max=100"` // Value is only included so you can pair up a user's answer with the original field Value interface{} `json:"value,omitempty" bson:"-"` }
Field is a generic Field that holds common properties of all Fields in a Form
func (*Field) GetDescription ¶
func (*Field) GetQuestion ¶
func (*Field) GetRequired ¶
type FieldInterface ¶
type FieldInterface interface { GetType() FieldType GetQuestion() string GetRef() string GetDescription() string GetRequired() bool GetTags() []string GetValue() interface{} SetValue(v interface{}) }
FieldInterface can be used to get common properties off of the various types of Field's on a Form
type Form ¶
type Form struct { FormMetadata `bson:",inline"` Fields []FieldInterface `json:"fields" bson:"f" validate:"min=1,max=500"` }
A Form is a group of Fields that can be submitted to TypeForm's [/forms](http://docs.typeform.io/docs/forms) endpoint
func (*Form) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface
type FormMetadata ¶
type FormMetadata struct { Title string `json:"title" bson:"t" validate:"min=1,max=256"` Tags []string `json:"tags,omitempty" bson:"g,omitempty" validate:"arrMap=min=1,arrMap=max=128,max=100"` WebhookURL string `json:"webhook_submit_url,omitempty" bson:"w,omitempty" validate:"validateURL"` DesignID string `json:"design_id,omitempty" bson:"d,omitempty" validate:"max=128"` }
FormMetadata represents everything about a Form except for the Fields
type MultipleChoice ¶
type MultipleChoice struct { Field `bson:",inline"` Choices []MultipleChoiceChoice `json:"choices" bson:"c" validate:"min=1,max=25"` }
MultipleChoice is a question that contains multiple choices
type MultipleChoiceChoice ¶
type MultipleChoiceChoice struct {
Label string `json:"label" bson:"l" validate:"nonzero, max=512"`
}
MultipleChoiceChoice is a choice in a MultipleChoice's Choices slice
type OpinionLabels ¶
type OpinionLabels struct { Left string `json:"left,omitempty" bson:"l,omitempty" validate:"max=100"` Center string `json:"center,omitempty" bson:"c,omitempty" validate:"max=100"` Right string `json:"right,omitempty" bson:"r,omitempty" validate:"max=100"` }
OpinionLabels represents a OpinionScale's labels property It contains a label for the left, center, and right sides of the scale
type OpinionScale ¶
type OpinionScale struct { Field `bson:",inline"` Steps int64 `json:"steps" bson:"s" validate:"min=5,max=11"` StartAtOne bool `json:"start_at_one,omitempty" bson:"sao,omitempty"` Labels OpinionLabels `json:"labels,omitempty" bson:"l,omitempty"` }
OpinionScale is a scale from 0-(steps - 1)