criterion

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 12 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(valueNode *yaml.Node, opts ...validation.Option) []error

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

type Criterion

type Criterion struct {
	marshaller.Model[core.Criterion]

	// 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
}

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

func (*Criterion) GetCondition added in v0.1.0

func (c *Criterion) GetCondition() (*Condition, error)

GetCondition will return the condition as a parsed condition object

func (*Criterion) Sync added in v0.1.6

func (c *Criterion) Sync(ctx context.Context) error

Sync will sync any changes made to the Arazzo document models back to the core models.

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 {
	marshaller.Model[core.CriterionExpressionType]

	// Type is the type of criterion.
	Type CriterionType
	// Version is the version of the criterion type.
	Version CriterionTypeVersion
}

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

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) 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.

func (*CriterionTypeUnion) Populate added in v0.2.1

func (c *CriterionTypeUnion) Populate(source any) error

type CriterionTypeVersion

type CriterionTypeVersion string

CriterionTypeVersion represents the version of the criterion type.

const (
	CriterionTypeVersionNone                            CriterionTypeVersion = ""
	CriterionTypeVersionDraftGoessnerDispatchJsonPath00 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