Documentation ¶
Overview ¶
Package formdata provides an interface to handle forms.
Index ¶
- type Anything
- type FieldErrors
- type FormData
- func (f *FormData) AllowUnknownFields()
- func (f *FormData) ConstructMapForDB() map[string]interface{}
- func (f *FormData) ConstructPartialMapForDB(part string) map[string]interface{}
- func (f *FormData) IsSet(key string) bool
- func (f *FormData) IsValid(key string) bool
- func (f *FormData) ParseJSONRequestData(r *http.Request) error
- func (f *FormData) ParseMapData(m map[string]interface{}) error
- func (f *FormData) RegisterTranslation(tag, text string)
- func (f *FormData) RegisterValidation(tag string, fn validator.Func)
- func (f *FormData) SetOldValues(oldValues interface{})
- func (f *FormData) ValidatorSkippingUnchangedFields(nestedValidator validator.Func) validator.Func
- func (f *FormData) ValidatorSkippingUnsetFields(nestedValidator validator.Func) validator.Func
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Anything ¶
type Anything struct {
// contains filtered or unexported fields
}
Anything represents a value of any type serialized as JSON.
func AnythingFromBytes ¶
AnythingFromBytes creates an instance of Anything with data from the given bytes slice.
func AnythingFromString ¶
AnythingFromString creates an instance of Anything with data from the given string.
func (Anything) MarshalJSON ¶
MarshalJSON of Anything copies the stored JSON data back.
func (*Anything) UnmarshalJSON ¶
UnmarshalJSON of Anything just copies the JSON data.
type FieldErrors ¶
FieldErrors represents multiple errors for form fields.
func (FieldErrors) Error ¶
func (e FieldErrors) Error() string
type FormData ¶
type FormData struct {
// contains filtered or unexported fields
}
FormData can parse JSON, validate it and construct a map for updating DB.
func NewFormData ¶
func NewFormData(definitionStructure interface{}) *FormData
NewFormData creates a new FormData object for given definitions.
func (*FormData) AllowUnknownFields ¶
func (f *FormData) AllowUnknownFields()
AllowUnknownFields disables the check for unknown fields in data.
func (*FormData) ConstructMapForDB ¶
ConstructMapForDB constructs a map for updating DB. It uses both the definition and the JSON input.
func (*FormData) ConstructPartialMapForDB ¶
ConstructPartialMapForDB constructs a map for updating DB. It uses both the definition and the JSON input.
func (*FormData) IsValid ¶
IsValid returns true if the field is valid (there are no errors for this field).
func (*FormData) ParseJSONRequestData ¶
ParseJSONRequestData parses and validates JSON from the request according to the structure definition.
func (*FormData) ParseMapData ¶
ParseMapData parses and validates map[string]interface{} according to the structure definition.
func (*FormData) RegisterTranslation ¶
RegisterTranslation registers translations against the provided tag.
func (*FormData) RegisterValidation ¶
RegisterValidation adds a validation with the given tag.
func (*FormData) SetOldValues ¶
func (f *FormData) SetOldValues(oldValues interface{})
SetOldValues sets the internal pointer to the structure containing old values for validation.
func (*FormData) ValidatorSkippingUnchangedFields ¶
ValidatorSkippingUnchangedFields constructs a validator checking only fields with changed values. You might want to call f.SetOldValues(oldValues) before in order to provide the form with previous field values.