Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddErrorsFromInput ¶
func AddErrorsFromInput(input interface{}, ea *ErrorAdder)
AddErrorsFromInput takes an input struct and adds validation errores using the ErrorAdder
func UnmarshalJSONAndAddErrors ¶
func UnmarshalJSONAndAddErrors(input interface{}, body io.ReadCloser, ea *ErrorAdder)
UnmarshalJSONAndAddErrors turns the JSON into a struct and adds relevant validation errors, including syntax errors
Types ¶
type ErrorAdder ¶
type ErrorAdder struct {
Errors *[]ErrorMessage
}
ErrorAdder is a struct used to add and write relevant request errors
func (ErrorAdder) Add ¶
func (ea ErrorAdder) Add(errorMessage ErrorMessage)
Add adds a new ErrorMessage to the ErrorAdder
func (ErrorAdder) Flush ¶
func (ea ErrorAdder) Flush(w http.ResponseWriter, httpStatus int)
Flush writes all the current errors in the ErrorAdder, and sets a relevant http status
func (ErrorAdder) HasErrors ¶
func (ea ErrorAdder) HasErrors() bool
HasErrors checks whether there are any errors in the ErrorAdder
type ErrorMessage ¶
ErrorMessage represents one error to be returned to the user
Click to show internal directories.
Click to hide internal directories.