Skip to content

fix: add birth year validation with minimum age requirement#765

Open
Muneerali199 wants to merge 1 commit intoAOSSIE-Org:devfrom
Muneerali199:fix-birthyear-validation-v2
Open

fix: add birth year validation with minimum age requirement#765
Muneerali199 wants to merge 1 commit intoAOSSIE-Org:devfrom
Muneerali199:fix-birthyear-validation-v2

Conversation

@Muneerali199
Copy link
Copy Markdown

@Muneerali199 Muneerali199 commented Feb 20, 2026

Fix: Invalid Birth Year Accepted During Signup

Description

Fixes #759: Invalid Birth Year Accepted During Signup.

This PR adds proper validation to prevent selecting future birth years and enforces a minimum age requirement of 18 years during user onboarding.


Changes Made

  • Prevent selecting future birth years
    Updated the date picker to disallow future dates.

  • Enforce minimum age of 18 years
    Added validation logic to ensure the user is at least 18 years old.

  • Add validation in onboarding screen
    Enhanced TextFormField validator with comprehensive date validation.

  • Add validation in controller
    Added backend validation in the saveProfile() method.


Technical Details

Files Modified

  • lib/controllers/onboarding_controller.dart

    • Updated chooseDate() to set initial date to 18 years ago
    • Added isValidBirthDate() helper method
    • Added backend validation with snackbar error messages
  • lib/views/screens/onboarding_screen.dart

    • Enhanced validator to check:
      • Empty dates
      • Invalid formats
      • Age requirements
    • Displays appropriate error messages

Validation Logic

  1. Prevents selection of future dates using:
    lastDate: DateTime.now()
  2. Enforces minimum age requirement of 18 years
  3. Validates date format (dd-MM-yyyy)
  4. Displays error messages:
    • "Enter Valid DOB" for empty or invalid format
    • "You must be at least 18 years old" for age violation

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Manual Testing

  1. Attempt to select a future date → prevented by date picker
  2. Select a date where user is under 18 → validation error shown
  3. Select a valid date (18+ years) → accepted
  4. Enter invalid date format → validation error shown
  5. Leave date field empty → validation error shown

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have checked my code and corrected any misspellings

Maintainer Checklist

- Prevent selecting future birth years
- Enforce minimum age of 18 years
- Add validation in onboarding screen and controller
- Fixes issue AOSSIE-Org#759: Invalid Birth Year Accepted During Signup
@Muneerali199 Muneerali199 requested a review from M4dhav as a code owner February 20, 2026 09:19
@github-actions
Copy link
Copy Markdown
Contributor

🎉 Welcome @Muneerali199!
Thank you for your pull request! Our team will review it soon. 🔍

  • Please ensure your PR follows the contribution guidelines. ✅
  • All automated tests should pass before merging. 🔄
  • If this PR fixes an issue, link it in the description. 🔗

We appreciate your contribution! 🚀

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 20, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

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.

1 participant