condition

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EQ     = "EQ"
	NE     = "NE"
	GT     = "GT"
	LT     = "LT"
	GE     = "GE"
	LE     = "LE"
	REGEXP = "REGEXP"
	IN     = "IN"
	NOTIN  = "NOTIN"
)

accepted condition operators

View Source
const (
	SKIP  = "skip"
	CHECK = "check"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Assert

type Assert struct {
	Value         string `json:"value"`
	Operator      string `json:"operator"`
	Expected      string `json:"expected"`
	ListSeparator string `json:"list_separator"`
	Message       string `json:"message"`
}

Assert describes a challenge to a value an expected value is compared through an operator the intent of this condition can be explained through a contextual message for clearer error surfacing

func (*Assert) Eval

func (a *Assert) Eval(v *values.Values, item interface{}, stepName string) error

Eval applies a condition on a particular item, asserting if the item meets the condition or not

func (*Assert) Valid

func (a *Assert) Valid() error

Valid asserts that a condition's definition is valid ie. the operator is among the accepted values listed above

type Condition

type Condition struct {
	Type    string            `json:"type"`
	If      []*Assert         `json:"if"`
	Then    map[string]string `json:"then"`
	Message string            `json:"message"`
}

Condition defines a condition to be evaluated before or after a step's action

func (*Condition) Eval

func (sc *Condition) Eval(v *values.Values, item interface{}, stepName string) error

Eval runs the condition against a set of values, evaluating the underlying Condition

type ErrConditionNotMet

type ErrConditionNotMet string

ErrConditionNotMet is the typed error returned by Condition when its evaluation fails

func (ErrConditionNotMet) Error

func (e ErrConditionNotMet) Error() string

Error implements standard error

Jump to

Keyboard shortcuts

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