-
Notifications
You must be signed in to change notification settings - Fork 56
Description
Description
Develop an endpoint that allows users to update an existing blog post comment. The endpoint should validate and sanitize the updated comment content, ensure the comment exists, and update the record in the database. The client should receive an appropriate response upon success or failure.
Acceptance Criteria
Accepts and validates the updated comment content using its ID.
Ensures the comment exists before updating.
Updates the comment in the database and records the timestamp of the last update.
Returns the appropriate response and status code.
Requirements
Endpoint:
Method: PATCH
URL: /api/v1/blogs/comments/{id}
Headers: Content-Type: application/json
Request Body:
{
"content": "string"
}
Responses:
✅ Successful Response
{
"message": "Comment updated successfully",
"success": true,
"status_code": 200
}
❌ Error Response (if comment is not found or validation fails)
{
"message": "Comment not found or invalid data",
"success": false,
"status_code": 400
}
Unit Tests
Validate that the comment content is correctly updated.
Ensure the database reflects the latest timestamp after the update.
Verify that an error response is returned when attempting to update a non-existent comment.