dag-cost / Exports / CelCostEvaluator
Class: CelCostEvaluator
Evaluates CEL (Common Expression Language) formulas to compute costs.
Results are always returned as finite number values. BigInt results from integer-only CEL expressions are coerced to number.
Table of contents
Constructors
Methods
Constructors
constructor
• new CelCostEvaluator(): CelCostEvaluator
Returns
Methods
evaluate
▸ evaluate(formula, context): TResult<number, IDagError>
Evaluate a CEL formula against the given context and return a numeric cost.
Parameters
| Name | Type | Description |
|---|---|---|
formula | string | CEL expression string (e.g. "baseCost + surcharge") |
context | Record<string, unknown> | variable bindings available inside the expression |
Returns
TResult<number, IDagError>
TResult\<number, IDagError\> — ok: true with the numeric value, or ok: false with a structured error
Defined in
services/cel-cost-evaluator.ts:18
validate
▸ validate(formula): TResult<void, IDagError>
Validate that a CEL formula is syntactically correct without evaluating it.
Parameters
| Name | Type | Description |
|---|---|---|
formula | string | CEL expression string |
Returns
TResult<void, IDagError>
TResult\<void, IDagError\> — ok: true if valid, ok: false with parse error details otherwise