validation

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 16 Imported by: 28

Documentation

Index

Constants

View Source
const (
	// Component name for monitoring.
	Component = "validation"

	// DefaultFilename is the default filename for the file containing
	// validation rules.
	// This is used in non-blockchain scenario.
	DefaultFilename = "/data/validation/rules.json"

	// DefaultPluginsDirectory is the default directory where validation
	// plugins should be stored.
	DefaultPluginsDirectory = "/data/validation/plugins"
)

Variables

View Source
var (
	ErrInvalidStepValidationRules = errors.New("a step validator requires a JSON schema, a signature or a transition criteria to be valid")
	ErrMissingPKI                 = errors.New("PKI is missing from validation rules")
	ErrMissingTransitions         = errors.New("transitions must be defined for every step")
	ErrInvalidTransitions         = errors.New("invalid step transition")
)

Errors used by the validation rules parsers.

Functions

func LoadFromFile

func LoadFromFile(ctx context.Context, validationCfg *Config) (validators.ProcessesValidators, error)

LoadFromFile loads the validation rules from a json file.

func RegisterFlags

func RegisterFlags()

RegisterFlags registers the command-line monitoring flags.

func WrapStoreWithConfigFile

func WrapStoreWithConfigFile(a store.Adapter, cfg *Config) (store.Adapter, error)

WrapStoreWithConfigFile wraps a store adapter with a layer of validations based on a local configuration file.

Types

type Config

type Config struct {
	RulesPath   string
	PluginsPath string
}

Config contains the path of the rules JSON file and the directory where the validator scripts are located.

func ConfigurationFromFlags

func ConfigurationFromFlags() *Config

ConfigurationFromFlags builds configuration from user-provided command-line flags.

type ProcessRules

type ProcessRules struct {
	PKI    validators.PKI           `json:"pki"`
	Steps  map[string]*StepRules    `json:"steps"`
	Script *validators.ScriptConfig `json:"script"`
}

ProcessRules contains the validation rules that apply to a specific process.

func (*ProcessRules) ValidateTransitions

func (r *ProcessRules) ValidateTransitions() error

ValidateTransitions checks for human errors in the transitions definitions (for example some steps that cannot be reached).

func (*ProcessRules) Validators

func (r *ProcessRules) Validators(process string, pluginsPath string) (validators.Validators, error)

Validators creates the validators corresponding to the configured process' rules.

type ProcessesRules

type ProcessesRules map[string]*ProcessRules

ProcessesRules maps processes to their validation rules.

func (ProcessesRules) Validators

func (r ProcessesRules) Validators(pluginsPath string) (validators.ProcessesValidators, error)

Validators creates the validators corresponding to the configured rules.

type StepRules

type StepRules struct {
	Signatures  []string               `json:"signatures"`
	Schema      map[string]interface{} `json:"schema"`
	Transitions []string               `json:"transitions"`
}

StepRules contains the validation rules that apply to a specific step inside a given process.

func (*StepRules) Validators

func (r *StepRules) Validators(process, step string, pki validators.PKI) (validators.Validators, error)

Validators creates the validators corresponding to the configured step's rules.

type StoreWithConfigFile

type StoreWithConfigFile struct {
	store.Adapter
	// contains filtered or unexported fields
}

StoreWithConfigFile wraps a store adapter with a layer of validations based on a local configuration file.

func (a *StoreWithConfigFile) CreateLink(ctx context.Context, link *chainscript.Link) (chainscript.LinkHash, error)

CreateLink applies validations before creating the link.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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