Skip to content

Conversation

@seapagan
Copy link
Owner

@seapagan seapagan commented Jan 16, 2026

What

Add EmailStr type to the email field in UserBase schema.

Why

Provides proper email validation at the Pydantic schema level,
ensuring consistent validation across all user schemas that inherit
from UserBase.

References

  • SECURITY-REVIEW.md #20

Summary by CodeRabbit

  • Improvements
    • Enhanced email validation during user registration with stricter validation checks to ensure only valid email addresses are accepted
    • Updated validation error responses to provide standardised, consistent feedback when users submit invalid email addresses

✏️ Tip: You can customize this high-level summary in your review settings.

Change email field from str to EmailStr for proper email validation
at the schema level. This provides consistent validation across all
user schemas that inherit from UserBase.

Also updates test to expect 422 (Pydantic validation) instead of
400 (application validation) for invalid email addresses.
@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

The changes introduce Pydantic's EmailStr type to replace string-based email validation in the user base schema. Corresponding test assertions and documentation are updated to reflect the stricter validation approach and resulting HTTP 422 status codes.

Changes

Cohort / File(s) Summary
Email Validation Schema Enhancement
app/schemas/base.py
Changed UserBase.email field type from str to EmailStr imported from Pydantic, enabling built-in email format validation at the schema level
Test Assertions Update
tests/integration/test_auth_routes.py
Updated registration error test to expect HTTP 422 (Pydantic validation error) instead of 400, and removed explicit error message assertion to accommodate standard validation response
Security Documentation
SECURITY-REVIEW.md
Added completion notes documenting the email validation enhancement via EmailStr adoption in base schema with reference to PR #817

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A rabbit hops through email fields,
Where EmailStr now validates,
No more loose strings, just proper seals,
Pydantic's might permeates!
Hop, hop, hooray! Our schemas celebrate! 📧

🚥 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 title accurately summarises the main change: adding EmailStr validation to the base schema, which is the primary focus of the PR across modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@seapagan seapagan self-assigned this Jan 16, 2026
@seapagan seapagan added the enhancement New feature or request label Jan 16, 2026
@seapagan seapagan merged commit 9fc3bb2 into main Jan 16, 2026
16 checks passed
@seapagan seapagan deleted the fix/email-validation-base-schema branch January 16, 2026 21:29
@codacy-production
Copy link

codacy-production bot commented Jan 16, 2026

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (1c39ffa) 2440 2440 100.00%
Head commit (e3a6a9d) 2440 (+0) 2440 (+0) 100.00% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#817) 2 2 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants