Skip to content

[Week7 - jbk] Task1: Add endpoints and input validation#47

Open
Candyroom136 wants to merge 1 commit into
week7-jbkfrom
week7-jbk-task1
Open

[Week7 - jbk] Task1: Add endpoints and input validation#47
Candyroom136 wants to merge 1 commit into
week7-jbkfrom
week7-jbk-task1

Conversation

@Candyroom136

Copy link
Copy Markdown

Summary

  • Add missing CRUD endpoints: DELETE /notes/{id}, DELETE /action-items/{id}, GET /action-items/{id}
  • Add input validation using Pydantic Field constraints (min_length, max_length)
  • Add query parameter validation for skip (ge=0) and limit (ge=1, le=200)

Problem

The existing API was missing DELETE endpoints for both resources and a single-item GET for action items. Input validation was absent — empty strings and negative pagination values were accepted without error.

Approach

  • Used Pydantic Field(...) with min_length/max_length to enforce non-empty inputs at the schema level
  • Added ge/le constraints on skip and limit query parameters
  • DELETE endpoints return 204 No Content on success, 404 if not found
  • Followed existing code patterns (HTTPException for 404, db.flush() for persistence)

Testing

$ make test
3 passed in 0.04s
All existing tests pass. New endpoints follow the same error handling patterns already covered by tests.

Tradeoffs & Follow-ups

  • Did not add dedicated tests for the new endpoints or validation errors (covered in Task 4)
  • max_length=200 for title matches the DB column constraint (String(200)) but could be surfaced as a friendlier error message
  • DELETE is a hard delete, not soft delete — no undo capability

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