xep0004

package
v0.62.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Boolean represents a 'boolean' form field.
	Boolean = "boolean"

	// Fixed represents a 'fixed' form field.
	Fixed = "fixed"

	// Hidden represents a 'hidden' form field.
	Hidden = "hidden"

	// JidMulti represents a 'jid-multi' form field.
	JidMulti = "jid-multi"

	// JidSingle represents a 'jid-single' form field.
	JidSingle = "jid-single"

	// ListMulti represents a 'list-multi' form field.
	ListMulti = "list-multi"

	// ListSingle represents a 'list-single' form field.
	ListSingle = "list-single"

	// TextMulti represents a 'text-multi' form field.
	TextMulti = "text-multi"

	// TextPrivate represents a 'text-private' form field.
	TextPrivate = "text-private"

	// TextSingle represents a 'text-single' form field.
	TextSingle = "text-single"
)
View Source
const (
	// Form represents a 'form' data form.
	Form = "form"

	// Submit represents a 'submit' data form.
	Submit = "submit"

	// Cancel represents a 'cancel' data form.
	Cancel = "cancel"

	// Result represents a 'result' data form.
	Result = "result"
)
View Source
const (
	// StringDataType datatype represents character strings in XML.
	StringDataType = "xs:string"

	// BooleanDataType represents the values of two-valued logic.
	BooleanDataType = "xs:boolean"

	// DecimalDataType represents a subset of the real numbers, which can be represented by decimal numerals.
	DecimalDataType = "xs:decimal"

	// FloatDataType is patterned after the IEEE single-precision 32-bit floating point datatype
	FloatDataType = "xs:float"

	// DoubleDataType is patterned after the IEEE double-precision 64-bit floating point datatype.
	DoubleDataType = "xs:double"

	// DurationDataType is a datatype that represents durations of time.
	DurationDataType = "xs:duration"

	// DateTimeDataType represents instants of time, optionally marked with a particular time zone offset.
	DateTimeDataType = "xs:dateTime"

	// HexBinaryDataType represents arbitrary hex-encoded binary data.
	HexBinaryDataType = "xs:hexBinary"

	// Base64BinaryDataType represents arbitrary Base64-encoded binary data
	Base64BinaryDataType = "xs:base64Binary"
)
View Source
const FormNamespace = "jabber:x:data"

FormNamespace specifies XEP-0004 namespace constant value.

View Source
const FormType = "FORM_TYPE"

FormType represents form type constant value.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicValidator added in v0.62.0

type BasicValidator struct{}

BasicValidator represents basic validation type.

func (*BasicValidator) Element added in v0.62.0

func (v *BasicValidator) Element() stravaganza.Element

Element satisfies Validator interface.

type DataForm

type DataForm struct {
	Type         string
	Title        string
	Instructions string
	Fields       Fields
	Reported     Fields
	Items        []Fields
}

DataForm represents a form that could be use for gathering data as well as for reporting data returned from a search.

func NewFormFromElement

func NewFormFromElement(elem stravaganza.Element) (*DataForm, error)

NewFormFromElement returns a new data form entity reading it from it's XMPP representation.

func (*DataForm) Element

func (f *DataForm) Element() stravaganza.Element

Element returns data form XML representation.

type Field

type Field struct {
	Var         string
	Required    bool
	Type        string
	Label       string
	Description string
	Values      []string
	Options     []Option
	Validate    *Validate
}

Field represents a field of a form. The field could be used to represent a question to complete, a completed question or a data returned from a search.

func NewFieldFromElement

func NewFieldFromElement(elem stravaganza.Element) (*Field, error)

NewFieldFromElement returns a new form field entity reading it from it's XML representation.

func (*Field) Element

func (f *Field) Element() stravaganza.Element

Element returns form field XML representation.

type Fields

type Fields []Field

Fields represent a set of form fields

func (Fields) ValueForField

func (f Fields) ValueForField(fieldName string) string

ValueForField returns the associated value for a given field name.

func (Fields) ValueForFieldOfType

func (f Fields) ValueForFieldOfType(fieldName, typ string) string

ValueForFieldOfType returns the associated value for a given field name and type.

func (Fields) ValuesForField

func (f Fields) ValuesForField(fieldName string) []string

ValuesForField returns all associated values for a given field name.

func (Fields) ValuesForFieldOfType

func (f Fields) ValuesForFieldOfType(fieldName, typ string) []string

ValuesForFieldOfType returns all associated values for a given field name and type.

type OpenValidator added in v0.62.0

type OpenValidator struct{}

OpenValidator represents open validation type.

func (*OpenValidator) Element added in v0.62.0

func (v *OpenValidator) Element() stravaganza.Element

Element satisfies Validator interface.

type Option

type Option struct {
	Label string
	Value string
}

Option represents an individual field option.

type RangeValidator added in v0.62.0

type RangeValidator struct {
	Min string
	Max string
}

RangeValidator represents range validation type.

func (*RangeValidator) Element added in v0.62.0

func (v *RangeValidator) Element() stravaganza.Element

Element satisfies Validator interface.

type RegExValidator added in v0.62.0

type RegExValidator struct {
	RegEx string
}

RegExValidator represents regex validation type.

func (*RegExValidator) Element added in v0.62.0

func (v *RegExValidator) Element() stravaganza.Element

Element satisfies Validator interface.

type Validate added in v0.62.0

type Validate struct {
	DataType  string
	Validator Validator
}

Validate represents a field validation type.

func (*Validate) Element added in v0.62.0

func (v *Validate) Element() stravaganza.Element

Element returns validation type element representation.

type Validator added in v0.62.0

type Validator interface {
	Element() stravaganza.Element
}

Validator defines validation type interface.

Jump to

Keyboard shortcuts

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