Add Min Max Validation for Count Related Policies - #2860
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe policy parameter editor now skips required-field validation for nested objects disabled through ChangesPolicy parameter validation
Workspace image configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
portals/ai-workspace/src/pages/appShell/PolicyParameterEditor/PolicyParameterEditor.tsx (1)
146-161: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression tests for the new validation branches.
Cover disabled objects with missing required children, disabled array items, an
anyOffalse branch withoutrequired: ['enabled'],min > max,min === max, and nested min/max paths.Also applies to: 189-193, 300-331
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@portals/ai-workspace/src/pages/appShell/PolicyParameterEditor/PolicyParameterEditor.tsx` around lines 146 - 161, Add regression tests for the validation logic around isDisabledByAnyOf and the related branches at the referenced validation paths. Cover disabled objects with missing required children, disabled array items, anyOf false branches lacking required enabled, min greater than max, min equal to max, and nested min/max paths, preserving expected validation outcomes for each case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@portals/ai-workspace/src/pages/appShell/PolicyParameterEditor/PolicyParameterEditor.tsx`:
- Around line 151-155: Update the supportsDisabled detection around
ParameterSchema.anyOf to identify any branch whose properties.enabled.const is
false, without requiring entry.required to include enabled. Preserve the
existing actual-value check and ensure branches lacking required are handled
correctly.
- Around line 189-193: Extend the disabled-object guard from the direct object
branch to the array-item validation path in PolicyParameterEditor, ensuring
validateRequiredFields skips object items where enabled is false or
isDisabledByAnyOf indicates they are disabled. Preserve validation for enabled
items and non-object array elements.
---
Nitpick comments:
In
`@portals/ai-workspace/src/pages/appShell/PolicyParameterEditor/PolicyParameterEditor.tsx`:
- Around line 146-161: Add regression tests for the validation logic around
isDisabledByAnyOf and the related branches at the referenced validation paths.
Cover disabled objects with missing required children, disabled array items,
anyOf false branches lacking required enabled, min greater than max, min equal
to max, and nested min/max paths, preserving expected validation outcomes for
each case.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: a5f72072-75d1-4809-b518-7799621e5384
📒 Files selected for processing (1)
portals/ai-workspace/src/pages/appShell/PolicyParameterEditor/PolicyParameterEditor.tsx
This pull request introduces improvements to the validation logic in the
PolicyParameterEditorcomponent, focusing on handling disabled parameter groups and enforcing logical constraints between minimum and maximum values. The main changes are grouped as follows:Issue: #2500

Validation logic improvements:
isDisabledByAnyOfhelper function to detect if a schema group is disabled via ananyOfentry with anenabled: falseproperty, allowing the validator to skip required checks for disabled groups.validateRequiredFieldsto skip validation for nested objects that are marked as disabled according to the schema and current values.validateConstraintsto check that, when bothminandmaxproperties are present and numeric, the maximum value is not less than the minimum value, and to report a clear error if this constraint is violated.Documentation and code clarity:
validateValueConstraintsto better reflect that it recursively validates format constraints, not just presence.