Break validationUtils.js (534 lines) into strategy pattern validators #2

Closed
opened 2026-03-11 13:53:59 +00:00 by vps1_gitea_admin · 0 comments

Problem

validationUtils.js is a 534-line god class handling all validation logic with a massive switch statement. Adding new node types requires modifying this central file.

Solution

Refactor into strategy pattern: one validator per concern (string, number, enum, range, etc.) with a registry.

Bugs found during audit

  • Line 274: says "Sorting..." but returns false instead of sorting
  • Line 257: unsafe Object.values() on curve data could lose info

Files affected

  • generalFunctions/src/helper/validationUtils.js

Acceptance criteria

  • Each validation type is a separate strategy class
  • New types can be added without modifying existing code
  • Fix the sorting bug at line 274
  • All existing tests still pass
## Problem validationUtils.js is a 534-line god class handling all validation logic with a massive switch statement. Adding new node types requires modifying this central file. ## Solution Refactor into strategy pattern: one validator per concern (string, number, enum, range, etc.) with a registry. ## Bugs found during audit - Line 274: says "Sorting..." but returns false instead of sorting - Line 257: unsafe Object.values() on curve data could lose info ## Files affected - generalFunctions/src/helper/validationUtils.js ## Acceptance criteria - [ ] Each validation type is a separate strategy class - [ ] New types can be added without modifying existing code - [ ] Fix the sorting bug at line 274 - [ ] All existing tests still pass
vps1_gitea_admin added the P0-architecture label 2026-03-11 13:53:59 +00:00
Sign in to join this conversation.