dynamic-forms / Function

isCrossFieldExpression

Detects if a ConditionalExpression references other fields (cross-field).

This is the core detection function that handles ALL expression types:

  • fieldValue with fieldPath → Always cross-field
  • formValue → Always cross-field
  • javascript with formValue.* in expression → Cross-field
  • custom → Checks registered function scope, defaults to cross-field if unknown
  • and/or → Recursively check nested conditions

Presentation

function isCrossFieldExpression(
  expr: boolean | ConditionalExpression | FormStateCondition | undefined,
  context?: CrossFieldDetectionContext | undefined,
): boolean;

Returns

boolean -

true if the expression references other fields

Parameters

NameTypeDescription
expr
boolean | ConditionalExpression | FormStateCondition | undefined

The conditional expression to analyze

context
CrossFieldDetectionContext | undefined

Optional context providing function scope lookup