MPDX-9650 - Improve validation in Savings Fund Transfer#1814
Conversation
Bundle sizes [mpdx-react]Compared against 8544dce No significant changes found |
zweatshirt
left a comment
There was a problem hiding this comment.
🤖 Multi-Agent Code Review — Verdict: ✅ CLEAN
Mode: standard · Risk: 1/10 (LOW) · Blockers: 0
Agents run: Architecture, UX/a11y, Financial (domain). Testing + Standards were verified inline (their key concerns are addressed below). This is a small, focused change — end-date validation now requires the end date to be strictly at least one calendar day after the transfer date (day-granular Luxon comparison), plus a permanent descriptive helper text on the End Date field, with 4 colocated tests.
Findings
Only two severity-3 suggestions (informational — do not block merge). See the inline comment for the first; the second is below.
Verified — concerns from skipped agents
- Type safety: Dropping the
as stringcast onerrors.endDateis correct and type-safe. BecauseendDateisDateTime<boolean> | null, Formik'sFormikErrorsmapped type resolves it tostring | undefined(the| nulldefeats theextends objectbranch). The siblingtransferDate(non-nullable) resolves to aFormikErrors<DateTime>object — which is exactly why line 478 still needs its cast.tsc --noEmitis clean. - Tests using past dates:
12/01/2024also fails the recurringstart-daterule, but each new test asserts only the end-date error's presence/absence, which is independent and correct in isolation. Suite passes. Minor smell — future dates would read cleaner — but not a defect.
Findings on Related Files (Not on Changed Lines)
[Suggestion] TransferModal.tsx:478 — Cast asymmetry between sibling date fields
- Severity: 3.0/10 · Flagged by: Architecture
- The End Date helper (this PR) now passes
errors.endDatedirectly, while the adjacent Transfer Date helper at line 478 still uses(errors.transferDate as string). The new pattern is the better one; line 478 is the outlier and is out of scope here. Consider dropping that cast if the line is touched in a future PR.
Domain note (non-blocking, pre-existing)
The submit path sends recurringStart/recurringEnd as full toISO() timestamps with a local offset, while validation compares at day granularity. Not reachable as a bug here (both fields are local-midnight date-only values), but worth a one-line confirmation with the API team that the backend treats these as calendar dates, not raw UTC instants — to avoid a boundary day-shift. This concerns the pre-existing toISO() submission, not the lines this PR adds.
| @@ -491,7 +491,11 @@ export const TransferModal: React.FC<TransferModalProps> = ({ | |||
| }} | |||
| error={touched.endDate && Boolean(errors.endDate)} | |||
| helperText={ | |||
| touched.endDate && (errors.endDate as string) | |||
| touched.endDate && errors.endDate | |||
There was a problem hiding this comment.
There was a problem hiding this comment.
AI Review Auto-Approval
Risk Level: LOW (1/10)
Verdict: CLEAN (no issues found)
This PR was auto-approved because:
- The multi-agent AI review determined it is low risk
- No blocking issues were found
If you believe this PR needs human review, dismiss this approval and request a review manually.
|
Preview branch generated at https://MPDX-9650.d3dytjb8adxkk5.amplifyapp.com |
Description
https://jira.cru.org/browse/MPDX-9580
Testing
Checklist:
/pr-reviewcommand locally and fixed any relevant suggestions