validation

package
v0.0.1-0...-104a2d1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ValidationError

type ValidationError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

func (ValidationError) Error

func (v ValidationError) Error() string

type ValidationErrors

type ValidationErrors []ValidationError

func TranslateErrors

func TranslateErrors(ctx context.Context, err error) ValidationErrors

TranslateErrors translates validation errors using i18n

func (ValidationErrors) Error

func (v ValidationErrors) Error() string

type Validator

type Validator struct {
	Validator *validator.Validate
}

func New

func New() *Validator

func (*Validator) ParseAndValidate

func (v *Validator) ParseAndValidate(ctx context.Context, r *http.Request, req interface{}) (ValidationErrors, error)

ParseAndValidate parses the request body and validates it

func (*Validator) RegisterCustomValidation

func (v *Validator) RegisterCustomValidation(tag string, fn validator.Func) error

RegisterCustomValidation registers custom validation functions

Jump to

Keyboard shortcuts

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