Documentation ¶
Overview ¶
Package validate provides a wrapper around the go-playground/validator package
Index ¶
- func Cause(err error) error
- func Check(val any) error
- func IsFieldError(err error) bool
- func IsInvalidRouteKeyError(err error) bool
- func IsRequestError(err error) bool
- func IsUnauthorizedError(err error) bool
- func NewRequestError(err error, status int) error
- func NewRouteKeyError(key string) error
- func NewUnauthorizedError() error
- type ErrorResponse
- type FieldError
- type FieldErrors
- type InvalidRouteKeyError
- type RequestError
- type UnauthorizedError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check a struct for validation errors and returns any errors the occur. This wraps the validate.Struct() function and provides some error wrapping. When a validator.ValidationErrors is returned, it is wrapped transformed into a FieldErrors array and returned.
func IsFieldError ¶
func IsInvalidRouteKeyError ¶
func IsRequestError ¶
IsRequestError checks if an error of type RequestError exists.
func IsUnauthorizedError ¶
func NewRequestError ¶
NewRequestError wraps a provided error with an HTTP status code. This function should be used when handlers encounter expected errors.
func NewRouteKeyError ¶
func NewUnauthorizedError ¶
func NewUnauthorizedError() error
Types ¶
type ErrorResponse ¶
ErrorResponse is the form used for API responses from failures in the API.
type FieldError ¶
FieldError is used to indicate an error with a specific request field.
func NewFieldError ¶
func NewFieldError(field, reason string) FieldError
type FieldErrors ¶
type FieldErrors []FieldError
FieldErrors represents a collection of field errors.
func NewFieldErrors ¶
func NewFieldErrors(errs ...FieldError) FieldErrors
func (FieldErrors) Append ¶
func (fe FieldErrors) Append(field, reason string) FieldErrors
func (FieldErrors) Error ¶
func (fe FieldErrors) Error() string
Error implements the error interface.
func (FieldErrors) Nil ¶
func (fe FieldErrors) Nil() bool
type InvalidRouteKeyError ¶
type InvalidRouteKeyError struct {
// contains filtered or unexported fields
}
func (*InvalidRouteKeyError) Error ¶
func (err *InvalidRouteKeyError) Error() string
type RequestError ¶
RequestError is used to pass an error during the request through the application with web specific context.
func (*RequestError) Error ¶
func (err *RequestError) Error() string
type UnauthorizedError ¶
type UnauthorizedError struct { }
func (*UnauthorizedError) Error ¶
func (err *UnauthorizedError) Error() string