Documentation
¶
Index ¶
- func NodesFromJSONSchema(ctx context.Context, group node.UiNodeGroup, jsonSchemaRef, prefix string, ...) (node.Nodes, error)
- type CSRFSetter
- type Container
- func New(action string) *Container
- func NewFromHTTPRequest(r *http.Request, group node.UiNodeGroup, action string, ...) (*Container, error)
- func NewFromJSON(action string, group node.UiNodeGroup, raw json.RawMessage, prefix string) *Container
- func NewFromJSONSchema(ctx context.Context, action string, group node.UiNodeGroup, ...) (*Container, error)
- func NewFromStruct(action string, group node.UiNodeGroup, v interface{}, prefix string) (*Container, error)
- func (c *Container) AddMessage(group node.UiNodeGroup, err *text.Message, setForFields ...string)
- func (c *Container) GetNodes() *node.Nodes
- func (c *Container) ParseError(group node.UiNodeGroup, err error) error
- func (c *Container) Reset(exclude ...string)
- func (c *Container) ResetMessages(exclude ...string)
- func (c *Container) Scan(value interface{}) error
- func (c *Container) SetCSRF(token string)
- func (c *Container) SetNode(n *node.Node)
- func (c *Container) SetValue(id string, n *node.Node)
- func (c *Container) SortNodes(ctx context.Context, opts ...node.SortOption) error
- func (c *Container) UnsetNode(id string)
- func (c *Container) UpdateNodeValuesFromJSON(raw json.RawMessage, prefix string, group node.UiNodeGroup)
- func (c *Container) Value() (driver.Value, error)
- type ErrorParser
- type FieldSorter
- type MessageResetter
- type NodeGetter
- type NodeSetter
- type NodeUnsetter
- type Resetter
- type ValueSetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NodesFromJSONSchema ¶
func NodesFromJSONSchema(ctx context.Context, group node.UiNodeGroup, jsonSchemaRef, prefix string, compiler *jsonschema.Compiler) (node.Nodes, error)
Types ¶
type CSRFSetter ¶
type CSRFSetter interface {
// SetCSRF sets the CSRF value.
SetCSRF(string)
}
type Container ¶
type Container struct {
// Action should be used as the form action URL `<form action="{{ .Action }}" method="post">`.
//
// required: true
Action string `json:"action" faker:"url"`
// Method is the form method (e.g. POST)
//
// required: true
Method string `json:"method" faker:"http_method"`
// Nodes contains the form's nodes
//
// The form's nodes can be input fields, text, images, and other UI elements.
//
// required: true
Nodes node.Nodes `json:"nodes"`
// Messages contains all global form messages and errors.
Messages text.Messages `json:"messages,omitempty"`
}
Container represents a HTML Form. The container can work with both HTTP Form and JSON requests
swagger:model uiContainer
func NewFromHTTPRequest ¶
func NewFromHTTPRequest(r *http.Request, group node.UiNodeGroup, action string, compiler decoderx.HTTPDecoderOption) (*Container, error)
NewFromHTTPRequest creates a new Container and populates fields by parsing the HTTP Request body. A jsonSchemaRef needs to be added to allow HTTP Form Post Body parsing.
func NewFromJSON ¶
func NewFromJSON(action string, group node.UiNodeGroup, raw json.RawMessage, prefix string) *Container
NewFromJSON creates a UI Container based on the provided JSON struct.
func NewFromJSONSchema ¶
func NewFromJSONSchema(ctx context.Context, action string, group node.UiNodeGroup, jsonSchemaRef, prefix string, compiler *jsonschema.Compiler) (*Container, error)
NewFromJSONSchema creates a new Container and populates the fields using the provided JSON Schema.
func NewFromStruct ¶ added in v0.11.0
func NewFromStruct(action string, group node.UiNodeGroup, v interface{}, prefix string) (*Container, error)
NewFromStruct creates a UI Container based on serialized contents of the provided struct.
func (*Container) AddMessage ¶
AddMessage adds the provided error, and if a non-empty names list is set, adds the error on the corresponding field.
func (*Container) ParseError ¶
func (c *Container) ParseError(group node.UiNodeGroup, err error) error
ParseError type asserts the given error and sets the container's errors or a field's errors and if the error is not something to be handled by the formUI Container, the error is returned.
This method DOES NOT touch the values of the node values/names, only its errors.
func (*Container) Reset ¶
Reset resets the container's errors as well as each field's value and errors.
func (*Container) ResetMessages ¶
ResetMessages resets the container's own and its node's messages.
func (*Container) UpdateNodeValuesFromJSON ¶
func (c *Container) UpdateNodeValuesFromJSON(raw json.RawMessage, prefix string, group node.UiNodeGroup)
UpdateNodeValuesFromJSON sets the container's fields to the provided values.
type ErrorParser ¶
type ErrorParser interface {
// ParseError type asserts the given error and sets the forms's errors or a
// field's errors and if the error is not something to be handled by the
// formUI Container itself, the error is returned for further propagation (e.g. showing a 502 status code).
ParseError(group node.UiNodeGroup, err error) error
}
ErrorParser is capable of parsing and processing errors.
type FieldSorter ¶
type MessageResetter ¶
type MessageResetter interface {
// ResetMessages resets the messages recursively.
ResetMessages(exclude ...string)
}
type NodeGetter ¶
type NodeSetter ¶
type NodeUnsetter ¶
type NodeUnsetter interface {
// UnsetFields removes a node.
UnsetNode(name string)
}
type Resetter ¶
type Resetter interface {
// Resets all values and messages recursively.
Reset(exclude ...string)
}