value

package
v0.0.0-...-6d13978 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeUnknown = Type("")

Functions

This section is empty.

Types

type Asset

type Asset = id.AssetID

type Bool

type Bool = bool

type DateTime

type DateTime = time.Time

type Group

type Group = id.ItemGroupID

type Integer

type Integer = int64

type Match

type Match struct {
	Asset          func(Asset)
	Bool           func(Bool)
	Checkbox       func(Bool)
	DateTime       func(DateTime)
	Integer        func(Integer)
	Number         func(Number)
	String         func(String)
	Text           func(String)
	TextArea       func(String)
	RichText       func(String)
	Markdown       func(String)
	Select         func(String)
	Tag            func(String)
	Reference      func(Reference)
	URL            func(URL)
	Group          func(Group)
	GeometryObject func(String)
	GeometryEditor func(String)
	Default        func()
}

type Multiple

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

func MultipleFrom

func MultipleFrom(t Type, v []*Value) *Multiple

func NewMultiple

func NewMultiple(t Type, v []any) *Multiple

func (*Multiple) Cast

func (m *Multiple) Cast(t Type) *Multiple

func (*Multiple) Clone

func (m *Multiple) Clone() *Multiple

func (*Multiple) Equal

func (m *Multiple) Equal(w *Multiple) bool

func (*Multiple) First

func (m *Multiple) First() *Value

func (*Multiple) Interface

func (m *Multiple) Interface() []any

Interface converts the value into generic representation

func (*Multiple) IsEmpty

func (m *Multiple) IsEmpty() bool

func (*Multiple) Len

func (m *Multiple) Len() int

func (*Multiple) Type

func (m *Multiple) Type() Type

func (*Multiple) Validate

func (m *Multiple) Validate() bool

func (*Multiple) Values

func (m *Multiple) Values() []*Value

func (*Multiple) ValuesAsset

func (m *Multiple) ValuesAsset() (vv []Asset, ok bool)

func (*Multiple) ValuesBool

func (m *Multiple) ValuesBool() (vv []bool, ok bool)

func (*Multiple) ValuesDateTime

func (m *Multiple) ValuesDateTime() (vv []DateTime, ok bool)

func (*Multiple) ValuesGroup

func (m *Multiple) ValuesGroup() (vv []Group, ok bool)

func (*Multiple) ValuesInteger

func (m *Multiple) ValuesInteger() (vv []Integer, ok bool)

func (*Multiple) ValuesNumber

func (m *Multiple) ValuesNumber() (vv []Number, ok bool)

func (*Multiple) ValuesReference

func (m *Multiple) ValuesReference() (vv []Reference, ok bool)

func (*Multiple) ValuesString

func (m *Multiple) ValuesString() (vv []String, ok bool)

func (*Multiple) ValuesURL

func (m *Multiple) ValuesURL() (vv []URL, ok bool)

type Number

type Number = float64

type Optional

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

func NewOptional

func NewOptional(t Type, v *Value) *Optional

func OptionalFrom

func OptionalFrom(v *Value) *Optional

func (*Optional) Cast

func (ov *Optional) Cast(t Type) *Optional

Cast tries to convert the value to the new type and generates a new Optional.

func (*Optional) Clone

func (ov *Optional) Clone() *Optional

func (*Optional) IsEmpty

func (ov *Optional) IsEmpty() bool

func (*Optional) IsNone

func (ov *Optional) IsNone() bool

func (*Optional) IsSome

func (ov *Optional) IsSome() bool

func (*Optional) Match

func (ov *Optional) Match(m OptionalMatch)

func (*Optional) SetValue

func (ov *Optional) SetValue(v *Value)

func (*Optional) Type

func (ov *Optional) Type() Type

func (*Optional) TypeAndValue

func (ov *Optional) TypeAndValue() (Type, *Value)

func (*Optional) Value

func (ov *Optional) Value() *Value

type OptionalMatch

type OptionalMatch struct {
	Match
	None func()
}

type Reference

type Reference = id.ItemID

type String

type String = string

type Type

type Type string
const TypeAsset Type = "asset"
const TypeBool Type = "bool"
const TypeCheckbox Type = "checkbox"
const TypeDateTime Type = "datetime"
const TypeGeometryEditor Type = "geometryEditor"
const TypeGeometryObject Type = "geometryObject"
const TypeGroup Type = "group"
const TypeInteger Type = "integer"
const TypeMarkdown Type = "markdown"
const TypeNumber Type = "number"
const TypeReference Type = "reference"
const TypeRichText Type = "richText"
const TypeSelect Type = "select"
const TypeTag Type = "tag"
const TypeText Type = "text"
const TypeTextArea Type = "textArea"
const TypeURL Type = "url"

func (Type) Default

func (t Type) Default() bool

func (Type) IsGeometryFieldType

func (t Type) IsGeometryFieldType() bool

func (Type) None

func (t Type) None() *Optional

func (Type) Value

func (t Type) Value(i any) *Value

func (Type) ValueFrom

func (t Type) ValueFrom(i any, p TypeRegistry) *Value

type TypeProperty

type TypeProperty interface {
	ToValue(any) (any, bool)
	ToInterface(any) (any, bool)
	Validate(any) bool
	IsEmpty(any) bool
	Equal(any, any) bool
}

type TypeRegistry

type TypeRegistry map[Type]TypeProperty

func (TypeRegistry) Find

func (r TypeRegistry) Find(t Type) (tp TypeProperty)

func (TypeRegistry) Get

func (r TypeRegistry) Get(t Type) TypeProperty

func (TypeRegistry) ToInterface

func (r TypeRegistry) ToInterface(t Type, v any) (any, bool)

func (TypeRegistry) ToValue

func (r TypeRegistry) ToValue(t Type, v any) (any, bool)

func (TypeRegistry) Validate

func (r TypeRegistry) Validate(t Type, v any) (bool, bool)

type URL

type URL = *url.URL

type Value

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

func New

func New(t Type, v any) *Value

func NewWithTypeRegistry

func NewWithTypeRegistry(t Type, v any, p TypeRegistry) *Value

func (*Value) AsMultiple

func (v *Value) AsMultiple() *Multiple

func (*Value) Cast

func (v *Value) Cast(t Type) *Value

func (*Value) Clone

func (v *Value) Clone() *Value

func (*Value) Equal

func (v *Value) Equal(w *Value) bool

func (*Value) Interface

func (v *Value) Interface() any

Interface converts the value into generic representation

func (*Value) IsEmpty

func (v *Value) IsEmpty() bool

func (*Value) Match

func (v *Value) Match(m Match)

func (*Value) Some

func (v *Value) Some() *Optional

func (*Value) Type

func (v *Value) Type() Type

func (*Value) TypeProperty

func (v *Value) TypeProperty() (tp TypeProperty)

func (*Value) Validate

func (v *Value) Validate() bool

func (*Value) Value

func (v *Value) Value() interface{}

func (*Value) ValueAsset

func (v *Value) ValueAsset() (vv Asset, ok bool)

func (*Value) ValueBool

func (v *Value) ValueBool() (vv bool, ok bool)

func (*Value) ValueDateTime

func (v *Value) ValueDateTime() (vv DateTime, ok bool)

func (*Value) ValueGroup

func (v *Value) ValueGroup() (vv Group, ok bool)

func (*Value) ValueInteger

func (v *Value) ValueInteger() (vv Integer, ok bool)

func (*Value) ValueNumber

func (v *Value) ValueNumber() (vv Number, ok bool)

func (*Value) ValueReference

func (v *Value) ValueReference() (vv Reference, ok bool)

func (*Value) ValueString

func (v *Value) ValueString() (vv String, ok bool)

func (*Value) ValueURL

func (v *Value) ValueURL() (vv URL, ok bool)

Jump to

Keyboard shortcuts

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