validator

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

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

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

type Validator

type Validator interface {
	Validate(
		body,
		auxiliaryValidatorFn interface{},
	) func(next http.Handler) http.Handler
}

Validator interface

Jump to

Keyboard shortcuts

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