dynamic-forms / Interface

EvaluationContext

Generic types:TValue

No documentation has been provided.

Properties

NameTypeDescription
arrayIndex
number | undefined

Current array index when inside an array derivation.

arrayPath
string | undefined

Path to the array field when inside an array derivation.

customFunctions
Record<string, (context: EvaluationContext<unknown>) => unknown> | undefined

Custom evaluation functions

externalData
Record<string, unknown> | undefined

External data signals resolved to their current values.

This allows forms to reference data from outside the form context in conditional logic, derivations, and other expressions.

Example usage
// In form config:
externalData: {
  userRole: computed(() => this.userService.currentRole()),
  permissions: computed(() => this.authService.permissions()),
}

// In JavaScript expression:
condition: {
  type: 'javascript',
  expression: "externalData.userRole === 'admin'"
}
fieldPath
string

Field path for relative references

fieldValue
TValue

Current field value

formValue
Record<string, unknown>

Form value for the current evaluation scope.

For regular (non-array) derivations, this contains the complete form value. For array item derivations, this is scoped to the current array item. Use rootFormValue to access the complete form when inside an array context.

logger
Logger

Logger for diagnostic output

rootFormValue
Record<string, unknown> | undefined

Root form value when inside an array context.

This provides access to values outside the current array item. When a derivation targets an array item field (e.g., items.$.lineTotal), formValue is scoped to the current array item, while rootFormValue provides access to the entire form value including fields outside the array.

Example usage
// In an array item derivation (on the lineTotal field inside lineItems array):
{
  key: 'lineTotal',
  type: 'input',
  // formValue = current array item { quantity: 2, unitPrice: 50 }
  // rootFormValue = entire form { globalDiscount: 0.1, lineItems: [...] }
  derivation: 'formValue.quantity * formValue.unitPrice * (1 - rootFormValue.globalDiscount)'
}

For non-array derivations, rootFormValue is not set and formValue contains the entire form value.