formdata

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

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

func AnythingFromBytes(bytes []byte) *Anything

AnythingFromBytes creates an instance of Anything with data from the given bytes slice

func AnythingFromString

func AnythingFromString(s string) *Anything

AnythingFromString creates an instance of Anything with data from the given string

func (Anything) Bytes

func (a Anything) Bytes() []byte

Bytes returns stored bytes

func (Anything) MarshalJSON

func (a Anything) MarshalJSON() ([]byte, error)

MarshalJSON of Anything copies the stored JSON data back

func (*Anything) UnmarshalJSON

func (a *Anything) UnmarshalJSON(raw []byte) error

UnmarshalJSON of Anything just copies the JSON data

type FieldErrors

type FieldErrors map[string][]string

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 added in v1.3.0

func (f *FormData) AllowUnknownFields()

AllowUnknownFields disables the check for unknown fields in data

func (*FormData) ConstructMapForDB

func (f *FormData) ConstructMapForDB() map[string]interface{}

ConstructMapForDB constructs a map for updating DB. It uses both the definition and the JSON input

func (*FormData) ConstructPartialMapForDB

func (f *FormData) ConstructPartialMapForDB(part string) map[string]interface{}

ConstructPartialMapForDB constructs a map for updating DB. It uses both the definition and the JSON input

func (*FormData) IsSet

func (f *FormData) IsSet(key string) bool

IsSet returns true if the field is set

func (*FormData) IsValid

func (f *FormData) IsValid(key string) bool

IsValid returns true if the field is valid (there are no errors for this field)

func (*FormData) ParseJSONRequestData

func (f *FormData) ParseJSONRequestData(r *http.Request) error

ParseJSONRequestData parses and validates JSON from the request according to the structure definition

func (*FormData) ParseMapData

func (f *FormData) ParseMapData(m map[string]interface{}) error

ParseMapData parses and validates map[string]interface{} according to the structure definition

func (*FormData) RegisterTranslation

func (f *FormData) RegisterTranslation(tag, text string)

RegisterTranslation registers translations against the provided tag

func (*FormData) RegisterValidation

func (f *FormData) RegisterValidation(tag string, fn validator.Func)

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

func (f *FormData) ValidatorSkippingUnchangedFields(nestedValidator validator.Func) validator.Func

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.

func (*FormData) ValidatorSkippingUnsetFields

func (f *FormData) ValidatorSkippingUnsetFields(nestedValidator validator.Func) validator.Func

ValidatorSkippingUnsetFields constructs a validator checking only fields given by the user

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL