MD.OFFICE
FAL

Daily Log - 2026-04-09

Dynaforms: Validation Hardening & Manual Operator Support

Achievements

  • Type Compatibility Guards: Implemented strict type checking for validation formulas in the FormulaBuilderComponent. The system now prevents semantically invalid comparisons like Date > Number or Currency == Date.
  • Expression Type Resolution: Developed a recursive resolver to determine the "dominant type" of an expression side, correctly identifying that Date - Date results in a numeric duration (number).
  • Manual Operator Input: Enabled users to manually type comparison operators (<, >, <=, >=, ==, !=) and logical operators (&, |) directly into the formula input field.
  • Enhanced Input Handling: Refactored the formula builder's backspace and insertion logic to handle multi-character operators seamlessly, ensuring the UI remains responsive and the formula string remains valid.

Decisions

  • Strict Mode for Dates: Decisions were made to treat Dates as a specialized type that is only comparable with other Dates. Raw numbers (literals) are explicitly blocked from direct comparison with Dates to prevent ambiguity.
  • Duration Support: Allowed subtraction between Dates to produce a Number, enabling duration-based validation rules like (EndDate - StartDate) < 30.
  • Literal Compatibility: Raw numeric literals remain compatible with Number and Currency fields to support standard threshold checks (e.g., amount > 500).

Technical Details

  • Modified: formula-builder.component.ts -> Implemented validateComparisonTypeCompatibility and resolveExpressionSideType.
  • Modified: formula-builder.component.ts -> Updated onKeyDown and regex patterns to support manual operator entry and multi-character token handling.
  • Modified: formula-builder.component.html -> Optimized template for real-time validation feedback.