parser

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(r io.Reader) (*model.Workflow, error)

Parse reads a duckflux workflow definition from r, validates it against the embedded JSON Schema, performs semantic validation, and returns a fully-populated *model.Workflow.

Errors returned are either a ValidationErrors (for schema / YAML / semantic problems) or a plain error for I/O failures.

Types

type ValidationError

type ValidationError struct {
	// Field is the JSON-pointer / dot-path of the offending field, e.g.
	// "/participants/coder/type" or "flow[2].loop".
	Field string
	// Message is a clear description of the failure.
	Message string
	// contains filtered or unexported fields
}

ValidationError represents a single structured validation failure returned by Parse or ValidateSchema. It carries an optional JSONPath-style location so callers can surface useful diagnostics.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap returns the underlying cause so errors.Is / errors.As traverse the chain correctly.

type ValidationErrors

type ValidationErrors []*ValidationError

ValidationErrors is a collection of ValidationError values that itself satisfies the error interface.

func ValidateInputs

func ValidateInputs(wf *model.Workflow, inputs map[string]any) ValidationErrors

ValidateInputs validates a map of runtime input values against the workflow's declared inputs schema. Values may originate from --input key=value CLI flags (stored as strings) or from an --input-file JSON document (stored as typed Go values after JSON unmarshaling).

The following checks are performed for each declared input field:

  • If required=true and no default is defined, the key must be present.
  • If the value is provided and a type is declared, the value must be compatible with that type (string, integer, number, boolean).
  • If the value is a string and a format is declared, the value must match that format (date, date-time, uri, email).

Returns nil when all inputs are valid.

func ValidateSemantic

func ValidateSemantic(wf *model.Workflow, celEnv *cel.Environment) ValidationErrors

ValidateSemantic performs post-parse semantic validation on a workflow:

  • participant names must not be reserved identifiers
  • flow step references must exist in the participants map
  • onError redirect targets must exist in the participants map
  • loop steps must specify at least one of until or max > 0
  • all CEL expressions must compile successfully

celEnv must be a CEL environment built from the same workflow so that participant variables are declared when expressions are type-checked. If there are no errors the returned slice is nil.

func (ValidationErrors) Error

func (ve ValidationErrors) Error() string

Error returns all validation messages joined by newlines.

Jump to

Keyboard shortcuts

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