validation

package
v0.0.0-...-d389d3b Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasValueChanged

func HasValueChanged[T comparable](value T, value2 T) bool

func Validate

func Validate[T any](ctx context.Context, subject *T, validationMethods []ValidationFunc[T]) error

func ValidationStep

func ValidationStep[T any](ctx context.Context, toBeValidated *T, v ValidationFunc[T]) error

Types

type EntityCreationValidator

type EntityCreationValidator[T common.EntityConstraint] interface {
	ValidateToCreate(ctx context.Context, entity *T) error
}

type EntityDeleteValidator

type EntityDeleteValidator[T common.EntityConstraint] interface {
	ValidateToDelete(ctx context.Context, entity *T) error
}

type EntityUpdateValidator

type EntityUpdateValidator[T common.EntityConstraint] interface {
	ValidateToUpdate(ctx context.Context, origin *T, updated *T) error
}

type ValidationError

type ValidationError struct {
	Message string
}

func (ValidationError) Error

func (v ValidationError) Error() string

type ValidationFieldError

type ValidationFieldError struct {
	Field   string
	Message string
	Value   any
}

func (ValidationFieldError) Error

func (v ValidationFieldError) Error() string

type ValidationFunc

type ValidationFunc[T any] func(ctx context.Context, subject *T) error

func ValidateChangeStep

func ValidateChangeStep[T any, V comparable](validationMethod ValidationFunc[T], value1 V, value2 V) ValidationFunc[T]

Jump to

Keyboard shortcuts

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