exprlang

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package exprlang compiles condition expressions for workflow DAG validation. It builds a typed environment from a JSON Schema (the predecessor node's outputSchema), then uses expr-lang to compile the expression — catching missing fields, wrong types, and syntax errors at validate time rather than at runtime.

SECURITY: SchemaToEnv and CompileCondition must not panic on adversarial or malformed input. JSON Schemas are user-authored (workflow definitions); duplicate field names after CamelCase conversion, invalid Go identifiers, and other edge cases are caught and returned as errors before reaching reflect.StructOf.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileCondition

func CompileCondition(expression string, schemaJSON []byte) error

CompileCondition compiles a single condition expression against the JSON-Schema-derived environment. Returns nil on success; on failure, returns an error detailing the type mismatch, missing field, or syntax error. Expressions reference fields via input.FieldName (CamelCase).

func SchemaToEnv

func SchemaToEnv(schemaJSON []byte) (map[string]any, error)

SchemaToEnv converts a JSON Schema (the predecessor node's outputSchema) into an expr-lang environment: a map with an "input" key whose value is a pointer to a reflect.StructOf-generated struct. The struct's fields are CamelCase versions of the JSON Schema's property names (snake_case, kebab-case, etc. all become CamelCase), with Go types derived from the schema's "type" keyword.

The returned environment type-checks strictly: missing fields and wrong types in expressions produce compile errors. A nil/empty schema produces a map[string]any environment (no type-checking); callers requiring strict checking should reject empty schemas upstream.

Types

This section is empty.

Jump to

Keyboard shortcuts

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