Skip to content

feat: add input validation for patient registration and updates#43

Open
uditv120 wants to merge 1 commit intobos-com:mainfrom
uditv120:fix/patient-input-validation
Open

feat: add input validation for patient registration and updates#43
uditv120 wants to merge 1 commit intobos-com:mainfrom
uditv120:fix/patient-input-validation

Conversation

@uditv120
Copy link
Copy Markdown

Summary

Implements input validation for patient registration and updates in PatientCreateSerializer (Issue #34).

Changes

File: apps/patients/serializers.py

Field-level validation

  • first_name / last_name: reject empty or whitespace-only strings
  • date_of_birth: reject future dates and implausible ages (>150 years)
  • phone_number: enforce E.164-like format (+ followed by 9–15 digits), strip spaces/dashes
  • email: validate format when provided (field is optional)
  • emergency_contact_phone: same phone format validation

Cross-field validation

  • emergency_contact_name is required when emergency_contact_phone is provided

Error messages

  • All messages use gettext_lazy for i18n support
  • Clear, user-friendly descriptions of what went wrong

Closes #34

- Validate first_name / last_name are not empty or whitespace-only
- Validate date_of_birth is not in the future and age is plausible (0-150)
- Validate phone_number matches E.164-like format (+ followed by 9-15 digits)
- Validate email format when provided
- Validate emergency_contact_phone format
- Add cross-field validation: emergency_contact_name required when phone given
- Return clear, translatable error messages via gettext_lazy

Closes bos-com#34
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.

Implement input validation for patient registration and updates

1 participant