Skip to content

feat: Add confirm password validation to the registration form#48

Open
shahinbashar wants to merge 2 commits intotemplate/layered-clean-architecturefrom
feat/confirm-password-validation
Open

feat: Add confirm password validation to the registration form#48
shahinbashar wants to merge 2 commits intotemplate/layered-clean-architecturefrom
feat/confirm-password-validation

Conversation

@shahinbashar
Copy link
Collaborator

@shahinbashar shahinbashar commented Feb 27, 2026

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

  • Added ConfirmPasswordValidation to verify password and confirm password match.
  • Wrapped registration inputs inside a Form widget for centralized validation handling.
  • Introduced a dedicated Confirm Password TextFormField.
  • Triggered form validation when the Continue button is pressed.

Purpose

Enhances registration security and reduces user errors by preventing mismatched passwords during account creation.

Screenshots

Registration Screen Validation State
registration validation

Notes

  • Validation logic remains separated from UI to maintain clean architecture principles.

Summary by CodeRabbit

  • New Features

    • Added password confirmation validation and integrated it into the registration form.
    • Implemented password visibility toggles for both password fields and real-time form validation with working submit handling.
  • Localization

    • Added "passwords do not match" translations for Arabic, Bengali, and English.

@shahinbashar shahinbashar self-assigned this Feb 27, 2026
Copilot AI review requested due to automatic review settings February 27, 2026 18:46
@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

📝 Walkthrough

Walkthrough

Added 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

Cohort / File(s) Summary
Localization files
lib/src/core/localization/intl_ar.arb, lib/src/core/localization/intl_bn.arb, lib/src/core/localization/intl_en.arb
Added passwordMismatchValidation translations and adjusted surrounding ARB syntax for the new entries.
Validation utilities
lib/src/core/utiliity/validation/confirm_password_validation.dart, lib/src/core/utiliity/validation/validation.dart
New ConfirmPasswordValidation class comparing input to a provided password provider; exported via the validation barrel.
Registration UI
lib/src/presentation/features/authentication/registration/view/registration_page.dart
Reworked registration form: added Form with GlobalKey<FormState>, password and confirm password TextEditingControllers, visibility toggles, autovalidation for password fields, confirm-password validator integration, controller disposal, and submit validation logic.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

enhancement

Suggested reviewers

  • momshaddinury
  • muhitmahmudbs23

Poem

🐰 I hopped through ARB and code today,
A twin-password check has come to play,
Controllers, toggles, messages in three—hooray!
I nibble bugs and let validations stay,
A tiny rabbit cheers the new display 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and accurately summarizes the main change: adding confirm password validation to the registration form, which is demonstrated throughout all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/confirm-password-validation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
lib/src/presentation/features/authentication/registration/view/registration_page.dart (1)

80-87: Consider using IconButton instead of GestureDetector for better accessibility.

IconButton provides 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

📥 Commits

Reviewing files that changed from the base of the PR and between af28e66 and 579144f.

⛔ Files ignored due to path filters (4)
  • lib/src/core/gen/l10n/app_localizations.dart is excluded by !**/gen/**
  • lib/src/core/gen/l10n/app_localizations_ar.dart is excluded by !**/gen/**
  • lib/src/core/gen/l10n/app_localizations_bn.dart is excluded by !**/gen/**
  • lib/src/core/gen/l10n/app_localizations_en.dart is excluded by !**/gen/**
📒 Files selected for processing (6)
  • lib/src/core/localization/intl_ar.arb
  • lib/src/core/localization/intl_bn.arb
  • lib/src/core/localization/intl_en.arb
  • lib/src/core/utiliity/validation/confirm_password_validation.dart
  • lib/src/core/utiliity/validation/validation.dart
  • lib/src/presentation/features/authentication/registration/view/registration_page.dart

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ConfirmPasswordValidation class to validate password matching
  • Wrapped registration form in a Form widget with validation support
  • Added password and confirm password fields with visibility toggles and controllers
  • Added passwordMismatchValidation localization 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 579144f and 6cecfa5.

📒 Files selected for processing (1)
  • lib/src/presentation/features/authentication/registration/view/registration_page.dart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants