validate

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConfig = errors.New("cannot validate, invalid configuration")
View Source
var ErrFailedRule = errors.New("Failed Rule")

Functions

func ConfigByField

func ConfigByField[T any](configReader io.Reader, fieldname string) (T, error)

func NewFailedRuleError

func NewFailedRuleError(rule string, id string) error

func ValidateFunc

func ValidateFunc[S ~[]E, E any](target S, check func(E) error) error

Types

type Validator

type Validator[ObjectT any, ConfigT any] struct {
	// contains filtered or unexported fields
}

func NewValidator

func NewValidator[ObjectT any, ConfigT any]() Validator[ObjectT, ConfigT]

func (Validator[ObjectT, ConfigT]) ReadConfigAndValidate

func (v Validator[ObjectT, ConfigT]) ReadConfigAndValidate(objects []ObjectT, configReader io.Reader, field string) error

func (Validator[ObjectT, ConfigT]) Validate

func (v Validator[ObjectT, ConfigT]) Validate(objects []ObjectT, config ConfigT) error

func (Validator[ObjectT, ConfigT]) WithAllowRules

func (v Validator[ObjectT, ConfigT]) WithAllowRules(rules ...func(ObjectT, ConfigT) bool) Validator[ObjectT, ConfigT]

func (Validator[ObjectT, ConfigT]) WithValidationRules

func (v Validator[ObjectT, ConfigT]) WithValidationRules(rules ...func([]ObjectT, ConfigT) error) Validator[ObjectT, ConfigT]

Jump to

Keyboard shortcuts

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