validator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewCache

func NewCache(l *zap.Logger) (*Cache, error)

func (*Cache) Get

func (c *Cache) Get(modelType ModelType, modelID ModelID) (*ValidationResult, bool)

func (*Cache) GetForType

func (c *Cache) GetForType(modelType ModelType) map[ModelID]*ValidationResult

func (*Cache) GetPool

func (c *Cache) GetPool() ValidationResults

func (*Cache) SetForType

func (c *Cache) SetForType(modelType ModelType, results map[ModelID]*ValidationResult)

type MessageCode

type MessageCode string

type ModelID

type ModelID string

type ModelType

type ModelType string

type ModelTypeInfo

type ModelTypeInfo struct {
	ModelType ModelType `json:"modelType"`
	Title     string    `json:"title"`
}

type ModelValidator

type ModelValidator interface {
	Validate(ctx context.Context, modelID ModelID) (*ValidationResult, *errors.ValidationError)
	ValidateAll(ctx context.Context) (map[ModelID]*ValidationResult, error)
}

type SysType

type SysType string

type ValidationResult

type ValidationResult struct {
	ID              ModelID                    `json:"id"`
	Title           string                     `json:"title,omitempty"`
	InternalTitle   string                     `json:"internalTitle,omitempty"`
	LastUpdatedDate string                     `json:"lastUpdatedDate,omitempty"`
	ModelType       ModelType                  `json:"modelType"`
	Health          constants.Health           `json:"health"`
	Messages        []*ValidationResultMessage `json:"messages"`
}

func InitEmptyValidationResult

func InitEmptyValidationResult(modelType ModelType, modelID ModelID, title string, internalTitle string, lastUpdatedDate string) *ValidationResult

func (*ValidationResult) Log

func (result *ValidationResult) Log(severity constants.Severity, message string, code MessageCode)

func (*ValidationResult) UpdateHealth

func (result *ValidationResult) UpdateHealth()

type ValidationResultMessage

type ValidationResultMessage struct {
	Code     MessageCode        `json:"code"`
	Message  string             `json:"message"`
	Severity constants.Severity `json:"severity"`
}

type ValidationResults

type ValidationResults map[ModelType]map[ModelID]*ValidationResult

type Validator

type Validator struct {
	Validators map[ModelType]ModelValidator
	Cache      *Cache
	// contains filtered or unexported fields
}

func NewValidator

func NewValidator(
	l *zap.Logger,
	csClient *client.Client,
	validatorProvider ValidatorProvider,
) (*Validator, error)

func (*Validator) Get

func (v *Validator) Get(modelType ModelType, modelID ModelID) (
	*ValidationResult,
	*errors.ValidationError,
)

func (*Validator) List

func (v *Validator) List(modelType ModelType) (
	map[ModelID]*ValidationResult,
	error,
)

func (*Validator) ListModelTypes

func (v *Validator) ListModelTypes() []ModelType

func (*Validator) MapListToCSV

func (v *Validator) MapListToCSV(modelType ModelType) (
	string,
	error,
)

func (*Validator) Update

func (v *Validator) Update(ctx context.Context)

func (*Validator) Validate

func (v *Validator) Validate(ctx context.Context, modelType ModelType, modelID ModelID) (
	*ValidationResult,
	*errors.ValidationError,
)

func (*Validator) ValidateAll

func (v *Validator) ValidateAll(ctx context.Context) error

type ValidatorProvider

type ValidatorProvider interface {
	GetValidators() map[ModelType]ModelValidator
}

Jump to

Keyboard shortcuts

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