refactor(core): split layout prop validation by concern#279
refactor(core): split layout prop validation by concern#279RtlZeroMemory merged 1 commit intomainfrom
Conversation
📝 WalkthroughWalkthroughIntroduces a modular layout validation architecture by decomposing layout property validation across five specialized modules (shared, primitives, spacing, layoutConstraints, interactive), then re-exports from a central barrel file. Moves approximately 1,188 lines of inline validation code to dedicated, cohesive validator modules without changing runtime behavior. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip Migrating from UI to YAML configuration.Use the |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/core/src/layout/validateProps.ts (1)
19-47: Please attach the mandatory layout PTY/frame-audit evidence.This rewires the core layout validation path, and the PR notes lint/typecheck/build/tests but not the live PTY validation the repo asks for on layout changes. Please include the
REZI_FRAME_AUDIT/frame-audit-report.mjsevidence before merge.Based on learnings: runtime/router/reconcile/layout/drawlist changes (high risk) need full test suite + integration coverage + PTY evidence; for rendering/layout/theme regressions, include mandatory live PTY validation: run app in PTY with deterministic viewport, exercise routes, capture REZI_FRAME_AUDIT logs, analyze with frame-audit-report.mjs, include concrete evidence in report.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/core/src/layout/validateProps.ts` around lines 19 - 47, This change rewires core layout validation (exports in validateProps.ts such as validateBoxProps, validateStackProps, validateTextProps, etc.), so run the mandated live PTY frame-audit: start the app in a deterministic PTY viewport with REZI_FRAME_AUDIT enabled, exercise relevant routes/components that touch the changed validators (box/stack/text/slider/etc.), capture the REZI_FRAME_AUDIT logs, run frame-audit-report.mjs to analyze them, and attach the generated frame-audit-report.mjs output (and raw REZI_FRAME_AUDIT logs) to the PR before merge.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/core/src/layout/validate/interactive.ts`:
- Around line 172-176: The validator functions currently cast arbitrary inputs
to prop bags (e.g., const p = (props ?? {}) as StackPropBag) which lets
non-object inputs like numbers/strings/arrays silently pass; change each
validator (validateStackProps, validateBoxProps, validateSpacerProps,
validateButtonProps, validateInputProps, validateSelectProps,
validateSliderProps, validateCheckboxProps, validateRadioGroupProps,
validateTextProps) to first check that props is a plain object (typeof props ===
"object" && props !== null && !Array.isArray(props)); if the check fails return
a failing LayoutResult, otherwise set p = props as <appropriate> and proceed to
apply defaults and validations—replace the existing (props ?? {}) as ... cast in
the listed functions with this guard so bad callers fail consistently.
In `@packages/core/src/layout/validate/shared.ts`:
- Around line 22-31: invalidProp currently uses String(received) which can run
user-defined coercion and throw; change invalidProp (and/or add a small helper
used by it) to safely stringify received by wrapping String(received) in a
try/catch (or perform a non-coercing check for primitives and fallback) and use
a safe fallback like "<unserializable>" when coercion throws, then pass that
safe string into invalid along with describeReceivedType to ensure validation
returns a LayoutResult instead of throwing; update references to invalidProp,
describeReceivedType, and invalid accordingly.
---
Nitpick comments:
In `@packages/core/src/layout/validateProps.ts`:
- Around line 19-47: This change rewires core layout validation (exports in
validateProps.ts such as validateBoxProps, validateStackProps,
validateTextProps, etc.), so run the mandated live PTY frame-audit: start the
app in a deterministic PTY viewport with REZI_FRAME_AUDIT enabled, exercise
relevant routes/components that touch the changed validators
(box/stack/text/slider/etc.), capture the REZI_FRAME_AUDIT logs, run
frame-audit-report.mjs to analyze them, and attach the generated
frame-audit-report.mjs output (and raw REZI_FRAME_AUDIT logs) to the PR before
merge.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1971379a-d804-460a-87e7-8edc3db4c04e
📒 Files selected for processing (6)
packages/core/src/layout/validate/interactive.tspackages/core/src/layout/validate/layoutConstraints.tspackages/core/src/layout/validate/primitives.tspackages/core/src/layout/validate/shared.tspackages/core/src/layout/validate/spacing.tspackages/core/src/layout/validateProps.ts
RtlZeroMemory
left a comment
There was a problem hiding this comment.
Reviewed the automated comments against the scope of this PR.
Summary
packages/core/src/layout/validateProps.tsinto internal validation modules.Why
Validation
Summary by CodeRabbit