Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNilValidator = errors.New("validator is nil")
)
Functions ¶
This section is empty.
Types ¶
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware struct is the validation middleware
func NewMiddleware ¶
func NewMiddleware( handler gonethttphandler.Handler, validator govalidatorstructmappervalidator.Service, generator govalidatorstructmapper.Generator, ) (*Middleware, error)
NewMiddleware creates a new Middleware instance
Parameters:
- handler: The HTTP handler to parse the request body
- validator: The struct validator service
- generator: The struct mapper generator
Returns:
- *Middleware: The middleware instance
- error: The error if any
func (Middleware) Validate ¶
func (m Middleware) Validate( body interface{}, auxiliaryValidatorFns ...govalidatorstructmappervalidator.AuxiliaryValidatorFn, ) func(next http.Handler) http.Handler
Validate validates the request body and stores it in the context
Parameters:
- body: An instance of the body to validate
- auxiliaryValidatorFns: Optional auxiliary validator functions
Returns:
- func(next http.Handler) http.Handler: The middleware function
Click to show internal directories.
Click to hide internal directories.