criterion

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition struct {

	// Expression is the expression to the value to be evaluated.
	Expression expression.Expression
	// Operator is the operator used to compare the value of the condition.
	Operator Operator
	// Value is the value to compare the value of the condition to.
	Value any
	// contains filtered or unexported fields
}

Condition represents a condition that will be evaluated for a given criterion.

func (*Condition) Validate

func (s *Condition) Validate(line, column int, opts ...validation.Option) []error

Validate will validate the condition is valid as per the Arazzo specification.

type Criterion

type Criterion struct {
	// Context is the expression to the value to be evaluated.
	Context *expression.Expression
	// Condition is the condition to be evaluated.
	Condition string
	// Type is the type of criterion. Defaults to CriterionTypeSimple.
	Type CriterionTypeUnion
	// Extensions provides a list of extensions to the Criterion object.
	Extensions *extensions.Extensions
	// contains filtered or unexported fields
}

Criterion represents a criterion that will be evaluated for a given step.

func (*Criterion) GetCore

func (c *Criterion) GetCore() *core.Criterion

GetCore will return the low level representation of the criterion object. Useful for accessing line and column numbers for various nodes in the backing yaml/json document.

func (*Criterion) Validate

func (c *Criterion) Validate(opts ...validation.Option) []error

Validate will validate the criterion object against the Arazzo specification.

type CriterionExpressionType

type CriterionExpressionType struct {
	// Type is the type of criterion.
	Type CriterionType
	// Version is the version of the criterion type.
	Version CriterionTypeVersion
	// contains filtered or unexported fields
}

CriterionExpressionType represents the type of expression used to evaluate the criterion.

func (*CriterionExpressionType) GetCore

GetCore will return the low level representation of the criterion expression type object. Useful for accessing line and column numbers for various nodes in the backing yaml/json document.

func (*CriterionExpressionType) IsTypeProvided

func (c *CriterionExpressionType) IsTypeProvided() bool

IsTypeProvided will return true if the criterion expression type has a type set.

func (*CriterionExpressionType) Validate

func (c *CriterionExpressionType) Validate(opts ...validation.Option) []error

Validate will validate the criterion expression type object against the Arazzo specification.

type CriterionType

type CriterionType string

CriterionType represents the type of criterion.

const (
	// CriterionTypeSimple indicates that the criterion represents a simple condition to be evaluated.
	CriterionTypeSimple CriterionType = "simple"
	// CriterionTypeRegex indicates that the criterion represents a regular expression to be evaluated.
	CriterionTypeRegex CriterionType = "regex"
	// CriterionTypeJsonPath indicates that the criterion represents a JSONPath expression to be evaluated.
	CriterionTypeJsonPath CriterionType = "jsonpath"
	// CriterionTypeXPath indicates that the criterion represents an XPath expression to be evaluated.
	CriterionTypeXPath CriterionType = "xpath"
)

type CriterionTypeUnion

type CriterionTypeUnion struct {
	// Type is the type of criterion.
	Type *CriterionType
	// ExpressionType is the type of the criterion and any version.
	ExpressionType *CriterionExpressionType
	// contains filtered or unexported fields
}

CriterionTypeUnion represents the union of a criterion type and criterion expression type.

func (*CriterionTypeUnion) FromCore

func (c *CriterionTypeUnion) FromCore(cr any) error

func (*CriterionTypeUnion) GetCore

GetCore will return the low level representation of the criterion type union object. Useful for accessing line and column numbers for various nodes in the backing yaml/json document.

func (CriterionTypeUnion) GetType

func (c CriterionTypeUnion) GetType() CriterionType

GetType will return the type of the criterion.

func (CriterionTypeUnion) GetVersion

GetVersion will return the version of the criterion type.

func (*CriterionTypeUnion) IsTypeProvided

func (c *CriterionTypeUnion) IsTypeProvided() bool

IsTypeProvided will return true if the criterion type union has a type set.

type CriterionTypeVersion

type CriterionTypeVersion string

CriterionTypeVersion represents the version of the criterion type.

const (
	CriterionTypeVersionNone                           CriterionTypeVersion = ""
	CriterionTypeVersionDraftGoesnerDispatchJsonPath00 CriterionTypeVersion = "draft-goessner-dispatch-jsonpath-00"
	CriterionTypeVersionXPath30                        CriterionTypeVersion = "xpath-30"
	CriterionTypeVersionXPath20                        CriterionTypeVersion = "xpath-20"
	CriterionTypeVersionXPath10                        CriterionTypeVersion = "xpath-10"
)

type Operator

type Operator string

Operator represents the operator used to compare the value of a criterion. TODO ignoring the Logical grouping, index & property de-reference operators for now as there is consistency issues with the spec on how/when these are used (they should probably be part of the expression type)

const (
	OperatorLT  Operator = "<"
	OperatorLTE Operator = "<="
	OperatorGT  Operator = ">"
	OperatorGTE Operator = ">="
	OperatorEQ  Operator = "=="
	OperatorNE  Operator = "!="
	OperatorNot Operator = "!" // TODO not entirely sure how this is supposed to work
	OperatorAnd Operator = "&&"
	OperatorOr  Operator = "||"
)

Jump to

Keyboard shortcuts

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