helpers

package
v0.0.0-...-3319774 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONResponse

func JSONResponse(c echo.Context, statusCode int, body ResponseMap) error

func JSONResponseArray

func JSONResponseArray(c echo.Context, statusCode int, collection []ResponseMap) error

func JSONResponseError

func JSONResponseError(c echo.Context, err *ResponseError) error

func JSONResponseObject

func JSONResponseObject(c echo.Context, statusCode int, object Responsible) error

Types

type Errors

type Errors struct {
	Messages map[string]string
}

Errors keep a record of the validation errors

func NewErrors

func NewErrors() *Errors

NewErrors creates a new instance of Errors

func (*Errors) Add

func (errors *Errors) Add(field string, message string)

Add adds a new error given a field and a message

func (*Errors) Clear

func (errors *Errors) Clear()

Clear removes all tracked errors.

func (*Errors) HasMessages

func (errors *Errors) HasMessages() bool

HasMessages returns true if the estructure is not empty.

func (*Errors) ValidateMaxValue

func (errors *Errors) ValidateMaxValue(value int, maxValueAllowed int, field string, message string)

ValidateMaxValue validates that the given value is greater than maxValueAllowed.

func (*Errors) ValidateMinValue

func (errors *Errors) ValidateMinValue(value int, minValueAllowed int, field string, message string)

ValidateMinValue validates that the given value is less than minValueAllowed.

type ResponseError

type ResponseError struct {
	Code    int
	Message string
}

func NewResponseError

func NewResponseError(httpCode int, message string) *ResponseError

func (*ResponseError) Error

func (err *ResponseError) Error() string

type ResponseMap

type ResponseMap map[string]interface{}

type Responsible

type Responsible interface {
	ToResponseMap() ResponseMap
}

Jump to

Keyboard shortcuts

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