Skip to content

Add task title validation for POST /tasks - #9

Closed
aj-enns wants to merge 1 commit into
mainfrom
aj-enns-add-input-validation-to-post-tasks
Closed

aj-enns wants to merge 1 commit into
mainfrom
aj-enns-add-input-validation-to-post-tasks

Conversation

@aj-enns

@aj-enns aj-enns commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds validation for POST /tasks so task creation only succeeds when the request includes a non-empty string title. Invalid requests now return a clear 400 JSON error and no task is created.

What changed

  • Added shared title validation and normalization for task creation.
  • Enforced the same validation in the task store so all creation paths behave consistently.
  • Updated API tests to cover the happy path, invalid title inputs, and whitespace trimming.
  • Added store-level tests to ensure blank titles are rejected and surrounding whitespace is trimmed.

Testing

  • Ran npm test in sample-app

Fixes: #1

Validate task titles before creation and trim surrounding whitespace.

This change adds shared validation so POST /tasks rejects missing,
empty, or non-string titles with a clear 400 JSON error and avoids
creating tasks for invalid input. It also ensures the store normalizes
whitespace and adds coverage for both API and store-level behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aj-enns aj-enns closed this Jun 26, 2026
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.

Add input validation to POST /tasks

1 participant