tinyformfields

package module
v0.0.0-...-58c92cc Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequiredFieldMissing = errors.New("required field missing")
	ErrInvalidChoice        = errors.New("invalid choice")
	ErrInvalidPattern       = errors.New("invalid pattern")
	ErrInvalidLength        = errors.New("invalid length")
	ErrInvalidEmail         = errors.New("invalid email")
	ErrInvalidURL           = errors.New("invalid URL")
	ErrInvalidTelephone     = errors.New("invalid telephone number")
	ErrInvalidColor         = errors.New("invalid color")
	ErrInvalidDate          = errors.New("invalid date")
	ErrInvalidTime          = errors.New("invalid time")
	ErrInvalidDateTime      = errors.New("invalid date and time")
	ErrLineBreakNotAllowed  = errors.New("line breaks not allowed")
	ErrInvalidFieldValue    = errors.New("invalid field value")
)

Functions

func ValidFormValues

func ValidFormValues(formFields []byte, values url.Values) error

ValidFormValues validates the form submission values against the form definition. Returns nil if validation passes, otherwise returns an error.

Types

type ChoiceFilter

type ChoiceFilter struct {
	Type      string `json:"type"`
	FieldName string `json:"fieldName"`
}

type ChooseMultipleField

type ChooseMultipleField struct {
	Type        string        `json:"type"` // "ChooseMultiple"
	Choices     []string      `json:"choices"`
	MinRequired *int          `json:"minRequired,omitempty"`
	MaxAllowed  *int          `json:"maxAllowed,omitempty"`
	Filter      *ChoiceFilter `json:"filter,omitempty"`
}

func (*ChooseMultipleField) UnmarshalJSON

func (f *ChooseMultipleField) UnmarshalJSON(data []byte) error

func (*ChooseMultipleField) Validate

func (f *ChooseMultipleField) Validate(value []string, field TinyFormField) error

type ChooseOneField

type ChooseOneField struct {
	Type    string        `json:"type"` // "ChooseOne"
	Choices []string      `json:"choices"`
	Filter  *ChoiceFilter `json:"filter,omitempty"`
}

func (*ChooseOneField) UnmarshalJSON

func (f *ChooseOneField) UnmarshalJSON(data []byte) error

func (*ChooseOneField) Validate

func (f *ChooseOneField) Validate(value []string, field TinyFormField) error
type DropdownField struct {
	Type    string        `json:"type"` // "Dropdown"
	Choices []string      `json:"choices"`
	Filter  *ChoiceFilter `json:"filter,omitempty"`
}
func (f *DropdownField) UnmarshalJSON(data []byte) error
func (f *DropdownField) Validate(value []string, field TinyFormField) error

type FieldType

type FieldType interface {
	Validate(value []string, field TinyFormField) error
}

type LongTextField

type LongTextField struct {
	Type      string `json:"type"` // "LongText"
	MaxLength *int   `json:"maxLength"`
}

func (*LongTextField) Validate

func (f *LongTextField) Validate(value []string, field TinyFormField) error

type ShortTextField

type ShortTextField struct {
	Type       string            `json:"type"` // "ShortText"
	InputType  string            `json:"inputType"`
	InputTag   string            `json:"inputTag,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

func (*ShortTextField) Validate

func (f *ShortTextField) Validate(value []string, field TinyFormField) error

type TinyFormField

type TinyFormField struct {
	Label          string                `json:"label"`
	Name           string                `json:"name,omitempty"`
	Description    string                `json:"description,omitempty"`
	Presence       TinyFormFieldPresence `json:"presence,omitempty"`
	Type           FieldType             `json:"type"`
	VisibilityRule []VisibilityRule      `json:"visibilityRule,omitempty"`
}

func (TinyFormField) FieldName

func (tff TinyFormField) FieldName() string

func (*TinyFormField) UnmarshalJSON

func (f *TinyFormField) UnmarshalJSON(data []byte) error

func (TinyFormField) Validate

func (tff TinyFormField) Validate(values url.Values) error

type TinyFormFieldPresence

type TinyFormFieldPresence struct {
	Type string `json:"type,omitempty"`
	Name string `json:"name,omitempty"`
}

func (TinyFormFieldPresence) MarshalJSON

func (p TinyFormFieldPresence) MarshalJSON() ([]byte, error)

func (*TinyFormFieldPresence) UnmarshalJSON

func (p *TinyFormFieldPresence) UnmarshalJSON(data []byte) error

type TinyFormFields

type TinyFormFields []TinyFormField

func (TinyFormFields) Validate

func (tffs TinyFormFields) Validate(values url.Values) error

type VisibilityComparison

type VisibilityComparison struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type VisibilityCondition

type VisibilityCondition struct {
	Type       string               `json:"type,omitempty"`
	FieldName  string               `json:"fieldName,omitempty"`
	Comparison VisibilityComparison `json:"comparison"`
}

type VisibilityRule

type VisibilityRule struct {
	Type       string                `json:"type"`
	Conditions []VisibilityCondition `json:"conditions"`
}

Jump to

Keyboard shortcuts

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