Documentation ¶
Overview ¶
Package validate provides a simple way to validate and parse data from HTTP requests.
Index ¶
- Constants
- func IsValidationError(err error) bool
- type Validate
- func (v Validate) JSONBodyInto(body io.ReadCloser, destStructPtr any) error
- func (v Validate) JSONBytesInto(data []byte, destStructPtr any) error
- func (v Validate) JSONStrInto(data string, destStructPtr any) error
- func (v Validate) URLSearchParamsInto(r *http.Request, destStructPtr any) error
- func (v Validate) UnmarshalFromBytes(data []byte, destStructPtr any) errordeprecated
- func (v Validate) UnmarshalFromRequest(r *http.Request, destStructPtr any) errordeprecated
- func (v Validate) UnmarshalFromResponse(r *http.Response, destStructPtr any) errordeprecated
- func (v Validate) UnmarshalFromString(data string, destStructPtr any) errordeprecated
Constants ¶
View Source
const ValidationErrorPrefix = "validation error: "
Variables ¶
This section is empty.
Functions ¶
func IsValidationError ¶ added in v0.0.42
IsValidationError returns true if the error is a validation error.
Types ¶
type Validate ¶
type Validate struct {
Instance *validator.Validate
}
Validate is a wrapper around the go-playground/validator package. It provides methods for validating and parsing data from HTTP requests.
func (Validate) JSONBodyInto ¶ added in v0.0.34
func (v Validate) JSONBodyInto(body io.ReadCloser, destStructPtr any) error
JSONBodyInto decodes the JSON body of an HTTP request into a struct and validates it.
func (Validate) JSONBytesInto ¶ added in v0.0.34
JSONBytesInto decodes a byte slice containing JSON data into a struct and validates it.
func (Validate) JSONStrInto ¶ added in v0.0.34
JSONStrInto decodes a string containing JSON data into a struct and validates it.
func (Validate) URLSearchParamsInto ¶ added in v0.0.34
URLSearchParamsInto parses the URL parameters of an HTTP request into a struct and validates it.
func (Validate) UnmarshalFromBytes
deprecated
added in
v0.0.17
func (Validate) UnmarshalFromString
deprecated
Click to show internal directories.
Click to hide internal directories.