Fix SC ENR parameters form validation for materials and clusters#1069
Fix SC ENR parameters form validation for materials and clusters#1069
Conversation
…o allow parameters with unactive clusters and material Signed-off-by: sBouzols <sylvain.bouzols@gmail.com>
📝 WalkthroughWalkthroughModified validation schemas and initial field values for short-circuit ICC cluster parameters. Introduced conditional validation requiring fields based on an Changes
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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.
🧹 Nitpick comments (1)
src/components/parameters/short-circuit/short-circuit-parameters-utils.ts (1)
135-135: Redundant.nullable()beforerequiredWhenActive.The
.nullable()chained on the base schema is redundant here sincerequiredWhenActivealready applies.nullable()in itsotherwisebranch. This also differs from the materials schema (line 88) which doesn't include.nullable()on the base.Consider removing for consistency:
♻️ Suggested refactor
- type: requiredWhenActive(yup.string().oneOf(['GENERATOR', 'HVDC']).nullable()), + type: requiredWhenActive(yup.string().oneOf(['GENERATOR', 'HVDC'])),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/parameters/short-circuit/short-circuit-parameters-utils.ts` at line 135, The base schema unnecessarily chains .nullable() before calling requiredWhenActive: remove the redundant .nullable() so the field is defined as type: requiredWhenActive(yup.string().oneOf(['GENERATOR', 'HVDC'])), matching the materials schema pattern; keep requiredWhenActive as the place that applies .nullable() in its otherwise branch to avoid double-nullable behavior and ensure consistency with the other schema.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/components/parameters/short-circuit/short-circuit-parameters-utils.ts`:
- Line 135: The base schema unnecessarily chains .nullable() before calling
requiredWhenActive: remove the redundant .nullable() so the field is defined as
type: requiredWhenActive(yup.string().oneOf(['GENERATOR', 'HVDC'])), matching
the materials schema pattern; keep requiredWhenActive as the place that applies
.nullable() in its otherwise branch to avoid double-nullable behavior and ensure
consistency with the other schema.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2b8a404c-e854-4d97-82be-aca53aa1c7ee
📒 Files selected for processing (3)
src/components/parameters/short-circuit/columns-definition.tssrc/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsxsrc/components/parameters/short-circuit/short-circuit-parameters-utils.ts
💤 Files with no reviewable changes (1)
- src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx




PR Summary
fix(): Add requiredWhenActive helper function and manage yup schema to allow parameters with inactive clusters and materials