feat: Add confirm password validation to the registration form#48
feat: Add confirm password validation to the registration form#48shahinbashar wants to merge 2 commits intotemplate/layered-clean-architecturefrom
Conversation
📝 WalkthroughWalkthroughAdded confirm-password validation: new localized key across three ARB files, a ConfirmPasswordValidation utility exported from the validation barrel, and registration UI updates to wire form state, controllers, visibility toggles, and confirmation validation. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as RegistrationPage
participant Validator as ConfirmPasswordValidation
participant Local as Localization
UI->>Validator: validate(confirmPassword)
Validator->>UI: needs originalPassword -> calls passwordProvider()
UI->>Validator: returns originalPassword
alt passwords match
Validator->>UI: null (no error)
else mismatch
Validator->>Local: request "passwordMismatchValidation" message
Local->>Validator: localized error string
Validator->>UI: localized error string
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
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: 3
🧹 Nitpick comments (1)
lib/src/presentation/features/authentication/registration/view/registration_page.dart (1)
80-87: Consider usingIconButtoninstead ofGestureDetectorfor better accessibility.
IconButtonprovides a proper touch target size (48x48 by default), built-in semantics for screen readers, and visual feedback (ripple effect). This applies to both password visibility toggles.♻️ Proposed refactor
- suffixIcon: GestureDetector( - onTap: _togglePasswordVisibility, - child: Icon( + suffixIcon: IconButton( + onPressed: _togglePasswordVisibility, + icon: Icon( _isPasswordVisible ? Icons.visibility_outlined : Icons.visibility_off_outlined, ), ),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/src/presentation/features/authentication/registration/view/registration_page.dart` around lines 80 - 87, Replace the GestureDetector used for the password visibility toggle with an IconButton to get proper touch target, semantics and ripple feedback: in the suffixIcon where GestureDetector wraps Icon, swap it for IconButton, wire its onPressed to _togglePasswordVisibility and use the same conditional icon (based on _isPasswordVisible); do the same replacement for the other password visibility toggle if present, and optionally set IconButton properties like splashRadius or constraints to match your layout.
🤖 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/src/presentation/features/authentication/registration/view/registration_page.dart`:
- Around line 115-120: The Continue button currently calls
_formKey.currentState?.validate() but ignores the boolean result; update the
FilledButton onPressed handler to capture the validation result (e.g., final
isValid = _formKey.currentState?.validate() ?? false) and only proceed when true
by calling the registration submit flow or navigation handler (call your
existing submit method or create a _submitRegistration/_onContinue method and
invoke it when isValid is true); keep the _formKey reference and FilledButton
onPressed as the single place to gate submission.
- Around line 62-72: The three TextFormField widgets for first name, last name,
and email are missing validations; update the first two TextFormField instances
to include a validator that applies RequiredValidation(), and update the email
TextFormField to include a validator that applies both RequiredValidation() and
EmailValidation() (e.g. combine/chain both validators in the email field's
validator). Locate the three TextFormField widgets in registration_page.dart and
add the appropriate validator parameter to each (firstName/lastName =>
RequiredValidation; email => RequiredValidation + EmailValidation) so the form
enforces presence and proper email format.
- Around line 74-90: The password TextFormField currently only uses
RequiredValidation; update its validator to enforce strength by applying the
existing PasswordValidation (from validation.dart) via context.validator.apply,
e.g. include PasswordValidation(...) alongside RequiredValidation so the field
checks min length, number, lowercase, uppercase and special-char rules; locate
the TextFormField using _passwordController, _isPasswordVisible and
_togglePasswordVisibility and replace the validator:
context.validator.apply([RequiredValidation()]) with a call that passes the
PasswordValidation instance(s) so localized error messages are used.
---
Nitpick comments:
In
`@lib/src/presentation/features/authentication/registration/view/registration_page.dart`:
- Around line 80-87: Replace the GestureDetector used for the password
visibility toggle with an IconButton to get proper touch target, semantics and
ripple feedback: in the suffixIcon where GestureDetector wraps Icon, swap it for
IconButton, wire its onPressed to _togglePasswordVisibility and use the same
conditional icon (based on _isPasswordVisible); do the same replacement for the
other password visibility toggle if present, and optionally set IconButton
properties like splashRadius or constraints to match your layout.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
lib/src/core/gen/l10n/app_localizations.dartis excluded by!**/gen/**lib/src/core/gen/l10n/app_localizations_ar.dartis excluded by!**/gen/**lib/src/core/gen/l10n/app_localizations_bn.dartis excluded by!**/gen/**lib/src/core/gen/l10n/app_localizations_en.dartis excluded by!**/gen/**
📒 Files selected for processing (6)
lib/src/core/localization/intl_ar.arblib/src/core/localization/intl_bn.arblib/src/core/localization/intl_en.arblib/src/core/utiliity/validation/confirm_password_validation.dartlib/src/core/utiliity/validation/validation.dartlib/src/presentation/features/authentication/registration/view/registration_page.dart
lib/src/presentation/features/authentication/registration/view/registration_page.dart
Show resolved
Hide resolved
lib/src/presentation/features/authentication/registration/view/registration_page.dart
Show resolved
Hide resolved
lib/src/presentation/features/authentication/registration/view/registration_page.dart
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR enhances the registration form by adding a confirm password field with validation to prevent password entry errors. The implementation adds form validation infrastructure, password visibility toggles, and multi-language support for the password mismatch error message.
Changes:
- Added
ConfirmPasswordValidationclass to validate password matching - Wrapped registration form in a
Formwidget with validation support - Added password and confirm password fields with visibility toggles and controllers
- Added
passwordMismatchValidationlocalization string in English, Bengali, and Arabic
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/presentation/features/authentication/registration/view/registration_page.dart | Added Form wrapper, password/confirm password fields with controllers and validation, visibility toggles |
| lib/src/core/utiliity/validation/confirm_password_validation.dart | New validation class that checks if password and confirm password match |
| lib/src/core/utiliity/validation/validation.dart | Exported the new ConfirmPasswordValidation class |
| lib/src/core/localization/intl_en.arb | Added English translation for password mismatch error |
| lib/src/core/localization/intl_bn.arb | Added Bengali translation for password mismatch error |
| lib/src/core/localization/intl_ar.arb | Added Arabic translation for password mismatch error |
| lib/src/core/gen/l10n/app_localizations_en.dart | Generated English localization code |
| lib/src/core/gen/l10n/app_localizations_bn.dart | Generated Bengali localization code |
| lib/src/core/gen/l10n/app_localizations_ar.dart | Generated Arabic localization code |
| lib/src/core/gen/l10n/app_localizations.dart | Added abstract getter for password mismatch validation string |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lib/src/presentation/features/authentication/registration/view/registration_page.dart
Outdated
Show resolved
Hide resolved
lib/src/presentation/features/authentication/registration/view/registration_page.dart
Show resolved
Hide resolved
lib/src/presentation/features/authentication/registration/view/registration_page.dart
Outdated
Show resolved
Hide resolved
lib/src/presentation/features/authentication/registration/view/registration_page.dart
Show resolved
Hide resolved
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/src/presentation/features/authentication/registration/view/registration_page.dart (1)
121-126: Continue button has no action after successful validation.The validation result is now checked correctly, but when the form is valid, the button does nothing. Consider adding a TODO comment or placeholder for the registration logic.
💡 Suggested improvement
FilledButton( onPressed: () { - if (!_formKey.currentState!.validate()) return; + if (_formKey.currentState?.validate() ?? false) { + // TODO: Proceed with registration + } }, child: Text(context.locale.continueAction), ),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/src/presentation/features/authentication/registration/view/registration_page.dart` around lines 121 - 126, The FilledButton's onPressed handler currently only validates the form via _formKey.currentState!.validate() and returns on failure, but performs no action when validation succeeds; update the onPressed closure in registration_page.dart (the FilledButton widget) to call the registration flow or at minimum add a clear TODO placeholder for future logic (e.g., call a registerUser / _submitRegistration method or dispatch a RegistrationSubmitted event) after successful validation, ensuring any necessary state saving via _formKey.currentState!.save() is invoked before proceeding.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@lib/src/presentation/features/authentication/registration/view/registration_page.dart`:
- Around line 121-126: The FilledButton's onPressed handler currently only
validates the form via _formKey.currentState!.validate() and returns on failure,
but performs no action when validation succeeds; update the onPressed closure in
registration_page.dart (the FilledButton widget) to call the registration flow
or at minimum add a clear TODO placeholder for future logic (e.g., call a
registerUser / _submitRegistration method or dispatch a RegistrationSubmitted
event) after successful validation, ensuring any necessary state saving via
_formKey.currentState!.save() is invoked before proceeding.
Summary
This PR improves the user registration flow by introducing a Confirm Password field to ensure users enter their intended password correctly before submission.
Changes
ConfirmPasswordValidationto verify password and confirm password match.Formwidget for centralized validation handling.TextFormField.Purpose
Enhances registration security and reduces user errors by preventing mismatched passwords during account creation.
Screenshots
Notes
Summary by CodeRabbit
New Features
Localization