MD.OFFICE
FAL

Daily Log - 2026-04-08

Dynaforms: Self-Referential Validation Formulas

Achievements

  • Self-Referential Validation: Enabled support for validation formulas to reference the field being validated (e.g., amount > 1000).
  • Contextual Suggestions: Updated the Formula Builder to include the current field in the @ suggestions dropdown specifically when configured for validation/error messages.
  • Value Injection: Modified FormEngineService to explicitly include the field's own value in the evaluation payload sent to the backend, ensuring validation logic can execute even if the field isn't a "reactive" dependency in the traditional sense.

Decisions

  • Calculation vs. Validation: Maintained the exclusion of self-references in calculation formulas to prevent infinite circular loops, while unlocking them for validation logic where they are semantically necessary.
  • Direct Payload Mapping: Opted to manually map values[ownJsonKey] = ownValue rather than adding the field to the dependency crawler, keeping the validator footprint clean and avoiding unnecessary re-evaluations.

Technical Details

  • Modified: error-i18n-parent.component.ts -> Added availableFieldsWithSelf to prepend the current field to suggestions.
  • Modified: form-engine.service.ts -> Updated attachFormulaValidators to populate the validation payload with the field's current value.