Documentation
¶
Index ¶
- func GetAllFieldtype() map[string]Definition
- func IsEmptyInput(input interface{}) bool
- func Register(definition Definition)
- type Definition
- type EmptyError
- type Event
- type FieldDef
- type FieldParameters
- type Handler
- type RelationParameters
- type StoreHandler
- type ValidateDefinition
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAllFieldtype ¶
func GetAllFieldtype() map[string]Definition
GetAllFieldtype get all fieldtype
func IsEmptyInput ¶
func IsEmptyInput(input interface{}) bool
IsEmptyInput returns if it's an empty input. The input can be not string(eg. int - definately not empty)
Types ¶
type Definition ¶
type Definition struct {
Name string //eg. text
DataType string //eg. string or eg "fieldtype.CustomString"
Package string //empty if there is no additional package, otherwise it's like 'mycompany.fieldtype'. Used for generating entity's import.
NewHandler func(FieldDef) Handler //callback to create new handler for this fieldtype
}
Definition includes a fieldtype basic information
type EmptyError ¶
type EmptyError struct {
}
Empty Error
func (EmptyError) Error ¶
func (err EmptyError) Error() string
type Event ¶
type Event interface {
BeforeStore(ctx context.Context, value interface{}, existing interface{}, mode string) (interface{}, error)
AfterDelete(ctx context.Context, value interface{}) error
}
BeforeSaving is implemented when fieldtype has event before saving and transaction starts.
type FieldDef ¶
type FieldDef struct {
Identifier string `json:"identifier"`
Name string `json:"name"`
FieldType string `json:"type"`
DefaultValue interface{} `json:"default_value"` //eg. checkbox 1 means checked
Required bool `json:"required"`
Description string `json:"description"`
IsOutput bool `json:"is_output"`
Parameters FieldParameters `json:"parameters"`
Children []FieldDef `json:"children"`
}
Content field definition
type FieldParameters ¶
type FieldParameters map[string]interface{}
type Handler ¶
type Handler interface {
//Load from input, should return the value of BaseType, (eg. int), return error or validation error or empty error
LoadInput(ctx context.Context, input interface{}, mode string) (interface{}, error)
//output database field. todo: can support this to generate database field automatically
DBField() string
}
Fieldtyper is a implementation of a fieldtype, including main logic
func GethHandler ¶
type RelationParameters ¶
type RelationParameters struct {
Type string `json:"type"`
Value string `json:"value"`
Condition map[string]interface{} `json:"condition"`
}
func ConvertRelationParams ¶
func ConvertRelationParams(params FieldParameters) (RelationParameters, error)
Convert to parameters obj
type StoreHandler ¶
type ValidateDefinition ¶
type ValidateDefinition interface {
ValidateDefinition() error
}
type ValidationError ¶
type ValidationError struct {
Message string
}
func NewValidationError ¶
func NewValidationError(message string) ValidationError
Click to show internal directories.
Click to hide internal directories.