fix: add type error handling for numeric fields in validation schemas#1073
fix: add type error handling for numeric fields in validation schemas#1073
Conversation
Signed-off-by: achour94 <berrahmaachour@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (2)
📝 WalkthroughWalkthroughAdds a new validation translation key Changes
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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/translations/fr/networkModificationsFr.ts (1)
134-134: Prefer the shared constant key in locale objects.Using the literal key here can drift from schema constants later. Use
[YUP_NOT_TYPE_NUMBER]like other shared validation keys.Proposed patch
-import { DUPLICATED_PROPS_ERROR, YUP_REQUIRED } from '../../utils'; +import { DUPLICATED_PROPS_ERROR, YUP_NOT_TYPE_NUMBER, YUP_REQUIRED } from '../../utils'; @@ - YupNotTypeNumber: "Ce champ n'accepte que des valeurs numériques", + [YUP_NOT_TYPE_NUMBER]: "Ce champ n'accepte que des valeurs numériques",🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/translations/fr/networkModificationsFr.ts` at line 134, Replace the literal translation key "YupNotTypeNumber" with the shared constant key YUP_NOT_TYPE_NUMBER (i.e., use [YUP_NOT_TYPE_NUMBER] as the object property) to match other locale entries; update the entry in src/translations/fr/networkModificationsFr.ts so the translations object uses the imported/shared constant YUP_NOT_TYPE_NUMBER rather than the hard-coded string, ensuring the constant is imported if not already.
🤖 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/translations/fr/networkModificationsFr.ts`:
- Line 134: Replace the literal translation key "YupNotTypeNumber" with the
shared constant key YUP_NOT_TYPE_NUMBER (i.e., use [YUP_NOT_TYPE_NUMBER] as the
object property) to match other locale entries; update the entry in
src/translations/fr/networkModificationsFr.ts so the translations object uses
the imported/shared constant YUP_NOT_TYPE_NUMBER rather than the hard-coded
string, ensuring the constant is imported if not already.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a57e5164-dbc2-47b0-95fb-74062cb531a3
📒 Files selected for processing (9)
src/components/network-modifications/common/connectivity/connectivityForm.utils.tssrc/components/network-modifications/common/measurements/powerWithValidity.utils.tssrc/components/network-modifications/common/setpoints/setPoints.utils.tssrc/components/network-modifications/load/creation/loadCreation.utils.tssrc/components/network-modifications/voltage-level/creation/voltageLevelCreation.utils.tssrc/components/network-modifications/voltage-level/modification/voltageLevelModification.utils.tssrc/translations/en/networkModificationsEn.tssrc/translations/fr/networkModificationsFr.tssrc/utils/constants/translationKeys.ts
|



PR Summary
Problem: When consuming commons-ui as a library, the yup.setLocale() config in yupConfig.ts may not be loaded, causing number() type validation errors to lose their translation key YupNotTypeNumber.
Fix — same pattern as required(YUP_REQUIRED):
This ensures the translation key is explicitly passed at the schema level, making it independent of yup.setLocale() being loaded.