Documentation
¶
Index ¶
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(definition.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 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 ¶
func GethHandler(def definition.FieldDef) Handler
type RelationParameters ¶
type RelationParameters struct {
Type string `json:"type"`
Value string `json:"value"`
Condition map[string]interface{} `json:"condition"`
}
func ConvertRelationParams ¶
func ConvertRelationParams(params definition.FieldParameters) (RelationParameters, error)
Convert to parameters obj
type StoreHandler ¶
type ValidationError ¶
type ValidationError struct {
Message string
}
func NewValidationError ¶
func NewValidationError(message string) ValidationError
Click to show internal directories.
Click to hide internal directories.