validations

package
v0.4.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilData        = errors.New("data cannot be nil")
	ErrNilMapper      = errors.New("mapper cannot be nil")
	ErrNilValidator   = errors.New("mapper validator cannot be nil")
	ErrNilValidations = errors.New("mapper validations cannot be nil")
	ErrFieldNotFound  = errors.New("field not found")
)

Functions

This section is empty.

Types

type DefaultValidations

type DefaultValidations struct {
	FailedFieldsValidations *map[string][]error
	NestedFieldsValidations *map[string]Validations
}

DefaultValidations is a struct that holds the error messages for failed validations of a struct

func NewDefaultValidations

func NewDefaultValidations() *DefaultValidations

NewDefaultValidations creates a new DefaultValidations struct

func (*DefaultValidations) AddFailedFieldValidationError

func (d *DefaultValidations) AddFailedFieldValidationError(
	fieldName string,
	validationError error,
)

AddFailedFieldValidationError adds a failed field validation error to the struct

func (*DefaultValidations) GetFailedFieldsValidations added in v0.4.0

func (d *DefaultValidations) GetFailedFieldsValidations() *map[string][]error

GetFailedFieldsValidations returns the failed fields validations

func (*DefaultValidations) GetNestedFieldsValidations added in v0.4.0

func (d *DefaultValidations) GetNestedFieldsValidations() *map[string]Validations

GetNestedFieldsValidations returns the nested struct fields validations

func (*DefaultValidations) HasFailed

func (d *DefaultValidations) HasFailed() bool

HasFailed returns true if there are failed validations

func (*DefaultValidations) SetNestedFieldsValidations added in v0.4.0

func (d *DefaultValidations) SetNestedFieldsValidations(
	fieldName string,
	nestedValidations Validations,
)

SetNestedFieldsValidations sets the nested struct fields validations to the struct

type Validations

type Validations interface {
	HasFailed() bool
	AddFailedFieldValidationError(
		fieldName string,
		validationError error,
	)
	SetNestedFieldsValidations(
		fieldName string,
		nestedValidations Validations,
	)
	GetFailedFieldsValidations() *map[string][]error
	GetNestedFieldsValidations() *map[string]Validations
}

Validations interface is an interface for struct fields validations

Jump to

Keyboard shortcuts

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