form

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2020 License: BSD-2-Clause Imports: 1 Imported by: 3

Documentation

Overview

Package form is an implementation of XEP-0004: Data Forms.

BE ADVISED: This API is unstable and subject to change.

Index

Constants

View Source
const NS = "jabber:x:data"

NS is the data forms namespace.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	// contains filtered or unexported fields
}

Data represents a data form.

func New

func New(o ...Field) *Data

New builds a new data form from the provided options.

func (*Data) MarshalXML

func (d *Data) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error)

MarshalXML satisfies the xml.Marshaler interface for *Data.

type Field

type Field func(*Data)

An Field is used to define the behavior and appearance of a data form.

func Boolean

func Boolean(id string, o ...Option) Field

Boolean fields enable an entity to gather or provide an either-or choice between two options.

func Fixed

func Fixed(o ...Option) Field

Fixed is intended for data description (e.g., human-readable text such as "section" headers) rather than data gathering or provision.

func Hidden

func Hidden(id string, o ...Option) Field

Hidden fields are not shown by the form-submitting entity, but instead are returned, generally unmodified, with the form.

func Instructions

func Instructions(s string) Field

Instructions adds new textual instructions to the form. Multiple uses of the option result in multiple sets of instructions.

func JID

func JID(id string, o ...Option) Field

JID enables an entity to gather or provide a Jabber ID.

func JIDMulti

func JIDMulti(id string, o ...Option) Field

JIDMulti enables an entity to gather or provide multiple Jabber IDs.

func ListMulti

func ListMulti(id string, o ...Option) Field

ListMulti enables an entity to gather or provide one or more entries from a list.

func ListSingle

func ListSingle(id string, o ...Option) Field

ListSingle enables an entity to gather or provide a single entry from a list.

func TextMulti

func TextMulti(id string, o ...Option) Field

TextMulti enables an entity to gather or provide multiple lines of text.

func TextPrivate

func TextPrivate(id string, o ...Option) Field

TextPrivate enables an entity to gather or provide a line of text that should be obscured in the submitting entities interface (eg. with multiple asterisks).

func TextSingle

func TextSingle(id string, o ...Option) Field

TextSingle enables an entity to gather or provide a line of text.

func Title

func Title(s string) Field

Title sets a form's title.

type Option

type Option func(*field)

A Option is used to define the behavior and appearance of a form field.

var (
	// Required flags the field as required in order for the form to be considered
	// valid.
	Required Option = required
)

func Desc

func Desc(s string) Option

Desc provides a natural-language description of the field, intended for presentation in a user-agent (e.g., as a "tool-tip", help button, or explanatory text provided near the field). Desc should not contain newlines (the \n and \r characters), since layout is the responsibility of a user agent. However, it does nothing to prevent them from being added.

func ListField

func ListField(s string) Option

ListField is one of the values in a list. It has no effect on any non-list field type.

func Value

func Value(s string) Option

Value defines the default value for the field (according to the form-processing entity) in a data form of type "form", the data provided by a form-submitting entity in a data form of type "submit", or a data result in a data form of type "result". Fields of type ListMulti, JidMulti, TextMulti, and Hidden may contain more than one Value; all other field types will only use the first Value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL