dynamic-forms / Function

createLogicFunction

Generic types:TValue

Create a logic function from a conditional expression.

This function is used for creating logic functions for hidden, readonly, disabled, and required. It uses the REACTIVE evaluation context, which allows the logic function to create reactive dependencies on form values. When dependent fields change, the logic function will be automatically re-evaluated.

NOTE: For validators, use createEvaluationContext directly (with untracked) to prevent infinite reactive loops. Validators with cross-field dependencies should be hoisted to form-level using validateTree.

Presentation

function createLogicFunction(
  expression: ConditionalExpression,
): LogicFn<TValue, boolean>;

Returns

LogicFn<TValue, boolean> -

A LogicFn that evaluates the condition in the context of a field

Parameters

NameTypeDescription
expression
ConditionalExpression

The conditional expression to evaluate