Skip to content

Feature/task sim 002 add pet age validation#2364

Open
BenjaminWong1205 wants to merge 2 commits intospring-projects:mainfrom
BenjaminWong1205:feature/TASK-SIM-002-add-pet-age-validation
Open

Feature/task sim 002 add pet age validation#2364
BenjaminWong1205 wants to merge 2 commits intospring-projects:mainfrom
BenjaminWong1205:feature/TASK-SIM-002-add-pet-age-validation

Conversation

@BenjaminWong1205
Copy link
Copy Markdown

[TASK-SIM-002] feat: add pet age validation

Summary

Added validation to ensure pet birth dates are in the past and pets are not older than 20 years.

Changes

  • ✅ Enhanced PetValidator with date range checks (Past & <20 years)
  • ✅ Removed duplicate validation logic from PetController
  • ✅ Added 5 comprehensive test cases for boundary conditions
  • ✅ Updated existing tests to match new error codes

Test Results

  • ✅ All tests passed (57/57)
  • Code Coverage: 94% (Target: ≥85%)
  • PetValidator coverage: 100%
  • ✅ Spring Java Format check passed

Testing Scenarios

Scenario Expected Actual
Pet born 5 years ago Pass
Pet born today (0 years) Pass
Pet born tomorrow (Future) Fail (birthDate.future)
Pet exactly 20 years old Pass
Pet 20 years + 1 day Fail (birthDate.tooOld)

Checklist

  • Code compiles without errors
  • All unit tests pass
  • Code coverage ≥ 85%
  • Code follows project conventions
  • Refactored controller validation logic

- Add PetValidator logic for birth date (past & <20 years)

- Remove duplicate validation from PetController

- Add 5 boundary test cases

- Coverage: 94% (PetValidator 100%)

- All tests passed

Closes TASK-SIM-002
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