validator

package
v0.5.13 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilMapper               = errors.New("mapper cannot be nil")
	ErrNilValidator            = errors.New("mapper validator cannot be nil")
	ErrFieldTagNameNotFound    = "field tag name not found: %s"
	ErrFieldIsRequiredNotFound = "field is required not found: %s"
	ErrRequiredField           = "%s is required"
)

Functions

This section is empty.

Types

type DefaultValidator

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

DefaultValidator struct

func NewDefaultValidator

func NewDefaultValidator(
	logger *Logger,
) *DefaultValidator

NewDefaultValidator creates a new default mapper validator

func (*DefaultValidator) IsFieldInitialized added in v0.5.5

func (d *DefaultValidator) IsFieldInitialized(
	fieldValue reflect.Value,
) (isInitialized bool)

IsFieldInitialized checks if a field is initialized

func (*DefaultValidator) ValidateRequiredFields added in v0.5.0

func (d *DefaultValidator) ValidateRequiredFields(
	rootStructValidations *govalidatormappervalidations.StructValidations,
	mapper *govalidatormapper.Mapper,
) error

ValidateRequiredFields validates the required fields of a struct

type Logger added in v0.4.6

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

Logger is the structs mapper validator logger

func NewLogger added in v0.4.6

func NewLogger(header string, modeLogger gologgermode.Logger) (*Logger, error)

NewLogger creates a new structs mapper validator logger

func (*Logger) InitializedField added in v0.5.5

func (l *Logger) InitializedField(
	structTypeName,
	fieldName string,
	fieldType reflect.Type,
	fieldValue interface{},
	required bool,
)

InitializedField prints the initialized field on debug mode

func (*Logger) UninitializedField added in v0.4.6

func (l *Logger) UninitializedField(
	structTypeName, fieldName string,
	fieldType reflect.Type,
	required bool,
)

UninitializedField prints the uninitialized field on debug mode

type Validator

type Validator interface {
	ValidateRequiredFields(
		rootStructValidations *govalidatormappervalidations.StructValidations,
		mapper *govalidatormapper.Mapper,
	) (err error)
}

Validator interface

Jump to

Keyboard shortcuts

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