validator

package
v0.0.0-...-c558e1b Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorHandler

type ErrorHandler struct {
	// contains filtered or unexported fields
}

func NewErrorHandler

func NewErrorHandler(l *logger.Logger) *ErrorHandler

func (*ErrorHandler) HandleError

func (h *ErrorHandler) HandleError(c *fiber.Ctx, err error) error

type ErrorType

type ErrorType int
const (
	ErrorTypeValidation ErrorType = iota
	ErrorTypeDatabase
	ErrorTypeBusiness
	ErrorTypeAuthentication
	ErrorTypeAuthorization
	ErrorTypeNotFound
	ErrorTypeInternal
	ErrorTypeTooManyRequests
)

func (ErrorType) String

func (et ErrorType) String() string

type InvalidParam

type InvalidParam struct {
	Name     string `json:"name"`
	Reason   string `json:"reason"`
	Code     string `json:"code,omitempty"`
	Location string `json:"location,omitempty"` // body, query, path, header
}

type ProblemDetail

type ProblemDetail struct {
	Type          string         `json:"type"`
	Title         string         `json:"title"`
	Status        int            `json:"status"`
	Detail        string         `json:"detail"`
	Instance      string         `json:"instance,omitempty"`
	InvalidParams []InvalidParam `json:"invalid-params,omitempty"`
	TraceID       string         `json:"trace_id,omitempty"`
}

type ValidationContext

type ValidationContext struct {
	IsCreate bool
	IsUpdate bool
}

func NewValidationContext

func NewValidationContext(ctx context.Context, valCtx *ValidationContext) *ValidationContext

Jump to

Keyboard shortcuts

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