page_fields

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DateLayout     = "Jan 02, 2006"
	TimeLayout     = "15:04 -0700"
	DateTimeLayout = "2006-01-02 15:04 MST"
)
View Source
var (
	DefaultParsers = Parsers{
		"bool":            BoolParser,
		"html":            HtmlParser,
		"string":          StringParser,
		"string-map":      StringMapParser,
		"string-slice":    StringSliceParser,
		"string-option":   StringOptionParser,
		"number":          NumberParser,
		"number-percent":  NumberPercentParser,
		"decimal":         DecimalParser,
		"decimal-percent": DecimalPercentParser,
		"email":           EmailParser,
		"path":            PathParser,
		"url":             UrlParser,
		"url-path":        UrlPathParser,
		"url-path-slice":  UrlPathSliceParser,
		"relative-url":    UrlPathParser,
		"time":            TimeParser,
		"date":            DateParser,
		"date-time":       DateTimeParser,
		"time-struct":     TimeStructParser,
		"language":        LanguageParser,
		"language-tag":    LanguageTagParser,
		"kebab":           KebabParser,
		"kebab-option":    KebabOptionParser,
		"uuid":            UuidParser,
	}
)

Functions

func AddDateTimeFormat

func AddDateTimeFormat(format string)

func BoolParser

func BoolParser(spec *Field, input interface{}) (parsed interface{}, err error)

func DateParser

func DateParser(spec *Field, input interface{}) (parsed interface{}, err error)

func DateTimeParser

func DateTimeParser(spec *Field, input interface{}) (parsed interface{}, err error)

func DecimalParser

func DecimalParser(spec *Field, input interface{}) (parsed interface{}, err error)

func DecimalPercentParser

func DecimalPercentParser(spec *Field, input interface{}) (parsed interface{}, err error)

func EmailParser

func EmailParser(spec *Field, input interface{}) (parsed interface{}, err error)

func HtmlParser

func HtmlParser(spec *Field, input interface{}) (parsed interface{}, err error)

func KebabOptionParser

func KebabOptionParser(spec *Field, input interface{}) (parsed interface{}, err error)

func KebabParser

func KebabParser(spec *Field, input interface{}) (parsed interface{}, err error)

func LanguageParser

func LanguageParser(spec *Field, input interface{}) (parsed interface{}, err error)

func LanguageTagParser

func LanguageTagParser(spec *Field, input interface{}) (parsed interface{}, err error)

func NumberParser

func NumberParser(spec *Field, input interface{}) (parsed interface{}, err error)

func NumberPercentParser

func NumberPercentParser(spec *Field, input interface{}) (parsed interface{}, err error)

func ParseTimeStructure

func ParseTimeStructure(input string) (parsed time.Time, err error)

func PathParser

func PathParser(spec *Field, input interface{}) (parsed interface{}, err error)

func StringMapParser

func StringMapParser(spec *Field, input interface{}) (parsed interface{}, err error)

func StringOptionParser

func StringOptionParser(spec *Field, input interface{}) (parsed interface{}, err error)

func StringParser

func StringParser(spec *Field, input interface{}) (parsed interface{}, err error)

func StringSliceParser

func StringSliceParser(spec *Field, input interface{}) (parsed interface{}, err error)

func TimeParser

func TimeParser(spec *Field, input interface{}) (parsed interface{}, err error)

func TimeStructParser

func TimeStructParser(spec *Field, input interface{}) (parsed interface{}, err error)

func ToKebab

func ToKebab(input string) (kebab string)

func UrlParser

func UrlParser(spec *Field, input interface{}) (parsed interface{}, err error)

func UrlPathParser

func UrlPathParser(spec *Field, input interface{}) (parsed interface{}, err error)

func UrlPathSliceParser

func UrlPathSliceParser(spec *Field, input interface{}) (parsed interface{}, err error)

func UuidParser

func UuidParser(spec *Field, input interface{}) (parsed interface{}, err error)

Types

type Field

type Field struct {
	Key      string `json:"key"`
	Tab      string `json:"tab"`
	Label    string `json:"label"`
	Format   string `json:"format"`
	Category string `json:"category"`

	Input    string `json:"input"`
	Weight   int    `json:"weight"`
	Required bool   `json:"required,omitempty"`

	Step         float64           `json:"step"`
	Minimum      float64           `json:"minimum"`
	Maximum      float64           `json:"maximum"`
	Placeholder  string            `json:"placeholder"`
	DefaultValue interface{}       `json:"default-value"`
	ValueLabels  map[string]string `json:"value-labels"`
	ValueOptions []string          `json:"value-options"`

	LockNonEmpty bool `json:"lock-non-empty"`
	NoResetValue bool `json:"no-reset-value"`

	Printer *message.Printer `json:"-"`
	Parse   Parser           `json:"-"`
}

func ParseField

func ParseField(data map[string]interface{}) (field *Field)

func (*Field) Copy

func (f *Field) Copy() (copied *Field)

type Fields

type Fields map[string]*Field

func (Fields) CategoryNames

func (f Fields) CategoryNames() (names []string)

func (Fields) Copy

func (f Fields) Copy() (copied Fields)

func (Fields) Init

func (f Fields) Init(printer *message.Printer, parsers Parsers)

func (Fields) Keys

func (f Fields) Keys() (keys []string)

func (Fields) Len

func (f Fields) Len() (count int)

func (Fields) Lookup

func (f Fields) Lookup(key string) (field *Field, ok bool)

func (Fields) SortedKeys

func (f Fields) SortedKeys() (keys []string)

func (Fields) TabCategoryFields

func (f Fields) TabCategoryFields(tab, category string, ignored ...string) (fields Fields)

func (Fields) TabCategoryNames

func (f Fields) TabCategoryNames(tab string) (keys []string)

func (Fields) TabFields

func (f Fields) TabFields(tab string) (fields Fields)

func (Fields) TabNames

func (f Fields) TabNames() (names []string)

type Parser

type Parser func(spec *Field, input interface{}) (parsed interface{}, err error)

type Parsers

type Parsers map[string]Parser

Jump to

Keyboard shortcuts

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