Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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, birthdateOptions *govalidatormappervalidator.BirthdateOptions, passwordOptions *govalidatormappervalidator.PasswordOptions, logger *slog.Logger, ) (*Middleware, error)
NewMiddleware creates a new Middleware instance
Parameters:
- handler: The HTTP handler to parse the request body
- birthdateOptions: The birthdate options (can be nil)
- passwordOptions: The password options (can be nil)
- logger: The logger (can be nil)
Returns:
- *Middleware: The middleware instance
- error: The error if any
func (Middleware) CreateValidateFn ¶
func (m Middleware) CreateValidateFn( bodyExample interface{}, cache bool, auxiliaryValidatorFns ...interface{}, ) (func(next http.Handler) http.Handler, error)
CreateValidateFn validates the request body and stores it in the context
Parameters:
- bodyExample: An example of the body to validate
- cache: Whether to cache the validation function or not
- auxiliaryValidatorFns: Optional auxiliary validator functions
Returns:
- func(next http.Handler) http.Handler: the validation middleware
- error: if there was an error creating the validation function
func (Middleware) Validate ¶
func (m Middleware) Validate( body interface{}, auxiliaryValidatorFns ...interface{}, ) func(next http.Handler) http.Handler
Validate validates the request body and stores it in the context
Parameters:
- body: The body to validate
- auxiliaryValidatorFns: Optional auxiliary validator functions
Returns:
- func(next http.Handler) http.Handler: the validation middleware
Click to show internal directories.
Click to hide internal directories.