refactor: change year format in both SaveCardDialog and SubscriptionPaymentDialog - #63
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR changes expiry-year handling from a 4-digit to a 2-digit short-year format across card and subscription payment flows. Validators now use a new private Sequence Diagram(s)sequenceDiagram
participant User
participant TextField
participant Formatter as _ExpiryYearTextInputFormatter
participant Validator as _parseFullYear / Validators
participant Dialog as Save/Subscription Dialog
participant Cubit as PaymentCubit
participant Backend
User->>TextField: type expiry year
TextField->>Formatter: new input
Formatter-->>TextField: sanitized/short-year value
TextField->>Validator: validation triggered (month/year checks)
Validator-->>TextField: validation result (uses _parseFullYear)
User->>Dialog: submit form
Dialog->>Dialog: _buildBackendExpiryYear(shortYear)
Dialog->>Cubit: pay(expiryYear: fullYear)
Cubit->>Backend: send payment payload (expiryYear "20xx")
Backend-->>Cubit: response
Cubit-->>Dialog: result (success/failure)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 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)
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
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/features/cards/presentation/widgets/save_card_dialog.dart`:
- Around line 223-226: The current inputFormatters for the expiry year field use
LengthLimitingTextInputFormatter(2) which clips pasted 4-digit years (e.g.,
"2026") to "20" causing incorrect validation; replace that with a custom
TextInputFormatter (implement a class like _ExpiryYearTextInputFormatter) that
strips non-digits, allows <=2 digits as-is, and when it detects exactly 4 digits
starting with "20" returns the last two digits (normalized) rather than
truncating—then use _ExpiryYearTextInputFormatter in the inputFormatters list
instead of LengthLimitingTextInputFormatter(2) so pastes of "2026" become "26"
and validations pass.
In
`@lib/features/subscriptions/presentation/widgets/subscription_payment_dialog.dart`:
- Around line 235-238: The expiry-year field currently applies
FilteringTextInputFormatter.digitsOnly and LengthLimitingTextInputFormatter(2)
which clips a pasted "2026" to "20" before validation; add a custom
TextInputFormatter (e.g. _ExpiryYearTextInputFormatter) that normalizes 4-digit
"20YY" input to the 2-digit "YY" form in formatEditUpdate before the
LengthLimitingTextInputFormatter runs, then replace/add this formatter in
subscription_payment_dialog.dart (and the save-card dialog equivalent) so pasted
full years are transformed to short years prior to length limiting and
validation.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d4ebbf6f-88b4-431e-bc42-40a0c09afcd1
📒 Files selected for processing (6)
lib/features/cards/presentation/validators/card_form_validators.dartlib/features/cards/presentation/widgets/save_card_dialog.dartlib/features/subscriptions/presentation/validators/subscription_payment_validators.dartlib/features/subscriptions/presentation/widgets/subscription_payment_dialog.darttest/features/cards/presentation/validators/card_form_validators_test.darttest/features/subscriptions/presentation/validators/subscription_payment_validators_test.dart
Summary by CodeRabbit
New Features
Refactor