Documentation
¶
Index ¶
- Constants
- func DecFunc[T Decoder](f func(io.Reader) T) func(io.Reader) Decoder
- func EncFunc[T Encoder](f func(io.Writer) T) func(io.Writer) Encoder
- func HelpText(helpText any) func(Field)
- func Hide(b bool) func(Field)
- func IsZero(value interface{}) bool
- func Label(label any) func(Field)
- func MaxLength(max int) func(Field)
- func MinLength(min int) func(Field)
- func Name(name string) func(Field)
- func ReadOnly(b bool) func(Field)
- func Regex(regex string) func(Field)
- func Required(b bool) func(Field)
- func Validators(validators ...func(interface{}) error) func(Field)
- func Widget(w widgets.Widget) func(Field)
- type BaseField
- func (i *BaseField) Attrs() map[string]string
- func (i *BaseField) Clean(value interface{}) (interface{}, error)
- func (i *BaseField) HasChanged(initial, data interface{}) bool
- func (i *BaseField) HelpText() string
- func (i *BaseField) Hide(hidden bool)
- func (i *BaseField) IsEmpty(value interface{}) bool
- func (i *BaseField) Label() string
- func (i *BaseField) Name() string
- func (i *BaseField) ReadOnly() bool
- func (i *BaseField) Required() bool
- func (i *BaseField) SetAttrs(attrs map[string]string)
- func (i *BaseField) SetHelpText(helpText func() string)
- func (i *BaseField) SetLabel(label func() string)
- func (i *BaseField) SetName(name string)
- func (i *BaseField) SetReadOnly(b bool)
- func (i *BaseField) SetRequired(b bool)
- func (i *BaseField) SetValidators(validators ...func(interface{}) error)
- func (i *BaseField) SetWidget(w widgets.Widget)
- func (i *BaseField) Validate(value interface{}) []error
- func (i *BaseField) ValueToForm(value interface{}) interface{}
- func (i *BaseField) ValueToGo(value interface{}) (interface{}, error)
- func (i *BaseField) Widget() widgets.Widget
- type Decoder
- type EmailFormField
- type Encoder
- type Field
- func BooleanField(opts ...func(Field)) Field
- func CharField(opts ...func(Field)) Field
- func DateField(typ widgets.DateWidgetType, opts ...func(Field)) Field
- func DecimalField(opts ...func(Field)) Field
- func EmailField(opts ...func(Field)) Field
- func NumberField[T widgets.NumberType](opts ...func(Field)) Field
- type FileStorageField
- type JSONFormField
- type MarshallerFormField
- type NullableSQLField
- type ProtectedFormField
- type SaveableField
Constants ¶
View Source
const (
ErrRegexInvalid = errs.Error("regex does not match")
)
Variables ¶
This section is empty.
Functions ¶
func Validators ¶
Types ¶
type BaseField ¶
type BaseField struct { FieldName string Required_ bool ReadOnly_ bool Attributes map[string]string Validators []func(interface{}) error FormLabel func() string FormHelpText func() string FormWidget widgets.Widget Caser *cases.Caser }
func (*BaseField) HasChanged ¶
func (*BaseField) SetHelpText ¶
func (*BaseField) SetReadOnly ¶
func (*BaseField) SetRequired ¶
func (*BaseField) SetValidators ¶
func (*BaseField) ValueToForm ¶
func (i *BaseField) ValueToForm(value interface{}) interface{}
type EmailFormField ¶
type EmailFormField struct {
*BaseField
}
func (*EmailFormField) ValueToForm ¶
func (e *EmailFormField) ValueToForm(value interface{}) interface{}
func (*EmailFormField) ValueToGo ¶
func (e *EmailFormField) ValueToGo(value interface{}) (interface{}, error)
type Field ¶
type Field interface { Attrs() map[string]string SetAttrs(attrs map[string]string) Hide(hidden bool) SetName(name string) SetLabel(label func() string) SetHelpText(helpText func() string) SetValidators(validators ...func(interface{}) error) SetWidget(widget widgets.Widget) Name() string Label() string HelpText() string Validate(value interface{}) []error Widget() widgets.Widget HasChanged(initial, data interface{}) bool Clean(value interface{}) (interface{}, error) ValueToForm(value interface{}) interface{} ValueToGo(value interface{}) (interface{}, error) Required() bool SetRequired(b bool) ReadOnly() bool SetReadOnly(b bool) IsEmpty(value interface{}) bool }
func BooleanField ¶
func DecimalField ¶ added in v1.6.7
func EmailField ¶
func NumberField ¶
func NumberField[T widgets.NumberType](opts ...func(Field)) Field
type FileStorageField ¶ added in v1.6.8
type FileStorageField struct { *BaseField StorageEngine string UploadTo func(fileObject *widgets.FileObject) string Validators []func(filename string, file io.Reader) error }
func FileField ¶ added in v1.6.8
func FileField(engine string, opts ...func(Field)) *FileStorageField
func (*FileStorageField) Save ¶ added in v1.6.8
func (f *FileStorageField) Save(value interface{}) (interface{}, error)
func (*FileStorageField) Widget ¶ added in v1.6.8
func (f *FileStorageField) Widget() widgets.Widget
type JSONFormField ¶
type JSONFormField[T any] struct { *MarshallerFormField[T] }
A wrapper around MarshallerFormField to better handle returned errors by ValueToGo
func JSONField ¶
func JSONField[T any](opts ...func(Field)) *JSONFormField[T]
func (*JSONFormField[T]) ValueToGo ¶
func (j *JSONFormField[T]) ValueToGo(value interface{}) (interface{}, error)
type MarshallerFormField ¶
type MarshallerFormField[T any] struct { *BaseField NewEncoder func(b io.Writer) Encoder NewDecoder func(b io.Reader) Decoder }
func MarshallerField ¶
func (*MarshallerFormField[T]) ValueToForm ¶
func (m *MarshallerFormField[T]) ValueToForm(value interface{}) interface{}
func (*MarshallerFormField[T]) ValueToGo ¶
func (m *MarshallerFormField[T]) ValueToGo(value interface{}) (interface{}, error)
type NullableSQLField ¶ added in v1.6.7
func SQLNullField ¶ added in v1.6.7
func SQLNullField[SQLType any](opts ...func(Field)) *NullableSQLField[SQLType]
func (*NullableSQLField[SQLType]) ValueToForm ¶ added in v1.6.7
func (n *NullableSQLField[SQLType]) ValueToForm(value interface{}) interface{}
func (*NullableSQLField[SQLType]) ValueToGo ¶ added in v1.6.7
func (n *NullableSQLField[SQLType]) ValueToGo(value interface{}) (interface{}, error)
func (*NullableSQLField[SQLType]) Widget ¶ added in v1.6.7
func (n *NullableSQLField[SQLType]) Widget() widgets.Widget
type ProtectedFormField ¶
Translates errors which might have too much information into a generic error message.
func (*ProtectedFormField) Clean ¶
func (pw *ProtectedFormField) Clean(value interface{}) (interface{}, error)
func (*ProtectedFormField) Validate ¶
func (pw *ProtectedFormField) Validate(value interface{}) []error
func (*ProtectedFormField) ValueToGo ¶
func (pw *ProtectedFormField) ValueToGo(value interface{}) (interface{}, error)
type SaveableField ¶ added in v1.6.8
Click to show internal directories.
Click to hide internal directories.