Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Choice ¶
type Choice struct {
types.QBase `json:",inline" bson:",inline"`
// Options is a list of options for the choice field.
// Validations:
// - required
// - at least one option
// - each option must be valid
Options []*Option `json:"options,omitempty" bson:"options,omitempty" validate:"required,min=1,dive"`
}
Choice represents a choice question type. Types: - types.QTypeSingleSelect - types.QTypeMultipleSelect - types.QTypeRadio - types.QTypeCheckbox
func CastToChoice ¶
CastToChoice casts the given interface to a Choice type.
func (*Choice) GetOptionsGroups ¶
GetOptionsGroups returns a map with each option and its associated groups. Key: Option name id Value: Groups ids
func (*Choice) RemoveGroupId ¶
RemoveGroupId removes the group with the specified name ID from the choice. Returns true if the group was removed, false otherwise.
type Option ¶
type Option struct {
// NameId is the identifier of the option.
// Validations:
// - required
// - valid name id
NameId string `json:"nameId" bson:"nameId" validate:"required,validNameId"`
// Label is a label for the option.
// Validations:
// - required
// - min length: 1
Label string `json:"label,omitempty" bson:"label,omitempty" validate:"required,min=1"`
// Value is the value of the option.
// Validations:
// - optional
// - min length: 1
Value any `json:"value,omitempty" bson:"value,omitempty" validate:"omitempty,min=1"`
// GroupsIds is a list of group ids that are associated with this option.
// Validations:
// - optional
GroupsIds []string `json:"groupsIds,omitempty" bson:"groupsIds,omitempty" validate:"omitempty"`
// Metadata is a map of metadata for the option.
// Validations:
// - optional
Metadata map[string]any `json:"metadata,omitempty" bson:"metadata,omitempty" validate:"omitempty"`
}
Option represents a single option in a choice widget.
type Slider ¶ added in v2.1.0
type Slider struct {
types.QBase `json:",inline" bson:",inline"`
// Min is the minimum value for the slider.
// Validations:
// - required
Min int `json:"min,omitempty" bson:"min,omitempty" validate:"required"`
// Max is the maximum value for the slider.
// Validations:
// - required
Max int `json:"max,omitempty" bson:"max,omitempty" validate:"required"`
// Step is the step value for the slider.
// Validations:
// - required
// - min: 1
Step int `json:"step,omitempty" bson:"step,omitempty" validate:"required,min=1"`
// Default is the default value for the slider.
// Validations:
// - optional
Default int `json:"default,omitempty" bson:"default,omitempty" validate:"omitempty"`
// Unit is the unit of the slider (e.g. years, months, days, etc.).
// Validations:
// - optional
// - min length: 1
Unit string `json:"unit,omitempty" bson:"unit,omitempty" validate:"omitempty,min=1"`
}
Slider represents a choice question type. Types: - types.QTypeSlider
func CastToSlider ¶ added in v2.1.0
CastToSlider casts an interface to a Slider type.
type Toggle ¶ added in v2.1.0
type Toggle struct {
types.QBase `json:",inline" bson:",inline"`
// Default is the default value for the toggle.
// Validations:
// - optional
Default bool `json:"default,omitempty" bson:"default,omitempty" validate:"omitempty"`
// OnLabel is the label for the "on" state.
// Validations:
// - required
// - min length: 1
OnLabel string `json:"onLabel,omitempty" bson:"onLabel,omitempty" validate:"required,min=1"`
// OffLabel is the label for the "off" state.
// Validations:
// - required
// - min length: 1
OffLabel string `json:"offLabel,omitempty" bson:"offLabel,omitempty" validate:"required,min=1"`
}
Toggle represents a toggle question type. Types: - types.QTypeToggle