validate

package
v0.13.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(r *http.Request, validator ...Validator) error

All runs all validators and returns an error if any of them fail. It returns a ErrBadRequest with all failed validation messages.

Types

type Validator

type Validator func(r *http.Request) (ok bool, reason string)

func HasEmptyBody

func HasEmptyBody() Validator

HasEmptyBody returns a validator that checks if the request body is empty.

func NoExtraQueryParams

func NoExtraQueryParams(except ...string) Validator

NoExtraQueryParams returns a validator that checks if the request has any query parameters that are not in the except list.

func QueryParamsContainsOneOf

func QueryParamsContainsOneOf(keys ...string) Validator

QueryParamsContainsOneOf returns a validator that checks if the request has at least one of the specified query parameters.

Jump to

Keyboard shortcuts

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