ENG-3522: Add client-side conditional validation for privacy center custom fields#8163
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
9d2d019 to
703d9d4
Compare
73195bc to
76cdac4
Compare
Code Review: ENG-3522 — Client-Side Conditional Validation for Privacy Center Custom FieldsPR: #8163 1. 🚨 Critical Issues (Must Fix)1.1
|
| Category | Count |
|---|---|
| 🚨 Critical (must fix) | 3 |
| 5 | |
| 💡 Suggestions (nits) | 5 |
| ✅ Good practices noted | 7 |
Overall assessment: This is a well-engineered feature. The core evaluator is pure, thoroughly tested, and mirrors backend behavior faithfully. The React integration layer has a few race conditions and edge-case concerns that should be addressed before merge, but nothing that fundamentally undermines the design.
Recommendation: Address issues 1.1, 1.2 (add console logging), and 2.1 (ref update timing) before merge. The remaining warnings are low-risk but worth fixing in a follow-up.
|
@rayharnett Updated. The changes: Addressed 1.1 — Silent error swallowing in evaluateCondition 1.2 — Silent cycle guard in resolveApplicableFields 1.3 — hasValue behavior for false/0 2.1 — Ref update race window 2.2 — setsEqual no early exit 2.3 — JSON.stringify circular ref risk 2.4 — Stale schema cache Skipped (no action needed)
|
Ticket ENG-3522
Description Of Changes
Adds client-side support for
display_conditionon custom privacy center form fields. When a field has adisplay_condition, it is evaluated against the current form values and shown/hidden reactively. Validation and submission are adjusted to exclude fields hidden by their conditions.This mirrors the backend's condition evaluation logic (ENG-3516) on the frontend, supporting the 5 display operators (
eq,neq,exists,not_exists,list_contains), condition groups withand/orlogic, and cascading dependencies via fixed-point iteration.Code Changes
ConditionLeaf,ConditionGroup,Condition,DisplayOperator) anddisplay_conditiontoICustomFieldintypes/config.tslib/condition-evaluator.ts— pure condition evaluator withevaluateCondition()andresolveApplicableFields()(fixed-point iteration for cascading deps)hooks/useApplicableFields.ts— React hook wrapping the evaluator with memoization (only recomputes when watched form values change)hooks/useCustomFieldsForm.ts— extractedbuildCustomFieldsValidationSchema()that accepts an optionalapplicableFieldssetusePrivacyRequestForm.ts— switched to Formikvalidatefunction for dynamic schema; added value clearing on hide; filters gated-off fields from submissionPrivacyRequestForm.tsx— filters rendered fields by applicable setuseConsentRequestForm.tsandConsentRequestForm.tsx— same pattern for consent flowSteps to Confirm
display_conditionon a custom field (e.g., show "State" only when "Country" equals "US")Pre-Merge Checklist
CHANGELOG.mdupdated